Selaa lähdekoodia

Set '\0' properly in StrnCpy()

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 <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Gary Lin 6 vuotta sitten
vanhempi
commit
5bb5032fda
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      lib/runtime/rtstr.c

+ 1 - 1
lib/runtime/rtstr.c

@@ -71,7 +71,7 @@ RtStrnCpy (
 {
     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));
 }