浏览代码

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 <glin@suse.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Gary Lin 6 年之前
父节点
当前提交
6058ffcd54
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      lib/runtime/rtstr.c

+ 2 - 2
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;
 }