diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c index cc41eb0343..91ce49235b 100644 --- a/MdePkg/Library/UefiLib/UefiLibPrint.c +++ b/MdePkg/Library/UefiLib/UefiLibPrint.c @@ -754,11 +754,15 @@ CatVSPrint ( SizeRequired = sizeof(CHAR16) + (CharactersRequired * sizeof(CHAR16)); } - BufferToReturn = AllocateCopyPool(SizeRequired, String); + BufferToReturn = AllocateZeroPool(SizeRequired); if (BufferToReturn == NULL) { return NULL; } + + if (String != NULL) { + StrCpyS(BufferToReturn, SizeRequired, String); + } UnicodeVSPrint(BufferToReturn + StrLen(BufferToReturn), (CharactersRequired+1) * sizeof(CHAR16), FormatString, Marker);