diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 65ce5bddce..0b526d0a02 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -2596,7 +2596,11 @@ GetQuestionDefault ( if (StrValue == NULL) { return EFI_NOT_FOUND; } - Question->BufferValue = AllocateCopyPool (StrSize (StrValue), StrValue); + if (Question->StorageWidth > StrSize (StrValue)) { + CopyMem (Question->BufferValue, StrValue, StrSize (StrValue)); + } else { + CopyMem (Question->BufferValue, StrValue, Question->StorageWidth); + } } return EFI_SUCCESS;