Fixed memory leak and buffer overrun for string op-code.

Signed-off-by:ydong10
Reviewed-by:lgao4



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12213 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ydong10 2011-08-26 01:54:49 +00:00
parent ce2f13a341
commit ba944801a9
1 changed files with 5 additions and 1 deletions

View File

@ -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;