]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiLib/UefiLibPrint.c
MdePkg/SmiHandlerProfile: Add Context support in Unregister
[mirror_edk2.git] / MdePkg / Library / UefiLib / UefiLibPrint.c
index 6eadc120c82021ad95d01ab11f0d17fbe9fc4752..9f52e7d0ceb8193c7403f572a7090869a53b3d66 100644 (file)
@@ -2,7 +2,7 @@
   Mde UEFI library API implementation.\r
   Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE\r
 \r
-  Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -742,8 +742,11 @@ CatVSPrint (
   UINTN   CharactersRequired;\r
   UINTN   SizeRequired;\r
   CHAR16  *BufferToReturn;\r
+  VA_LIST ExtraMarker;\r
 \r
-  CharactersRequired = SPrintLength(FormatString, Marker);\r
+  VA_COPY (ExtraMarker, Marker);\r
+  CharactersRequired = SPrintLength(FormatString, ExtraMarker);\r
+  VA_END (ExtraMarker);\r
 \r
   if (String != NULL) {\r
     SizeRequired = StrSize(String) + (CharactersRequired * sizeof(CHAR16));\r
@@ -751,14 +754,16 @@ CatVSPrint (
     SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16));\r
   }\r
 \r
-  BufferToReturn = AllocateZeroPool(SizeRequired);\r
+  BufferToReturn = AllocatePool(SizeRequired);\r
 \r
   if (BufferToReturn == NULL) {\r
     return NULL;\r
+  } else {\r
+    BufferToReturn[0] = L'\0';\r
   }\r
 \r
   if (String != NULL) {\r
-    StrCpy(BufferToReturn, String);\r
+    StrCpyS(BufferToReturn, SizeRequired / sizeof(CHAR16), String);\r
   }\r
 \r
   UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);\r