From 6058ffcd54cffea196c5aadef4ba5b5af6114648 Mon Sep 17 00:00:00 2001 From: Gary Lin Date: Thu, 11 Oct 2018 16:10:26 +0800 Subject: Set '\0' properly in StpnCpy() The arguments to SetMem() were wrong. Besides, SetMem() should start at "Dest + Size" since "Size" will be smaller than "Len" if they are not equal. Signed-off-by: Gary Lin Signed-off-by: Nigel Croxon --- lib/runtime/rtstr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/runtime/rtstr.c b/lib/runtime/rtstr.c index dcc1a2a..65cc018 100644 --- a/lib/runtime/rtstr.c +++ b/lib/runtime/rtstr.c @@ -94,7 +94,7 @@ RtStpCpy ( } #ifndef __GNUC__ -#pragma RUNTIME_CODE(RtStrnCpy) +#pragma RUNTIME_CODE(RtStpnCpy) #endif CHAR16 * RUNTIMEFUNCTION @@ -107,7 +107,7 @@ RtStpnCpy ( { UINTN Size = RtStrnLen(Src, Len); if (Size != Len) - RtSetMem(Dest + Len, '\0', (UINT8)((Len - Size) * sizeof(CHAR16))); + RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); RtCopyMem(Dest, Src, Size * sizeof(CHAR16)); return Dest + Size; } -- cgit v1.2.1