Add check to make code more safely.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15655 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong 2014-07-14 11:01:17 +00:00 committed by ydong10
parent 93551a01fe
commit e77d2f9db2
1 changed files with 5 additions and 2 deletions

View File

@ -2590,6 +2590,7 @@ FindQuestionFromProgress (
// For Name/Value type, Skip the ConfigHdr part.
//
EndStr = StrStr (Progress, L"PATH=");
ASSERT (EndStr != NULL);
while (*EndStr != '&') {
EndStr++;
}
@ -2600,6 +2601,7 @@ FindQuestionFromProgress (
// For Buffer type, Skip the ConfigHdr part.
//
EndStr = StrStr (Progress, L"&OFFSET=");
ASSERT (EndStr != NULL);
*EndStr = '\0';
}
@ -2615,6 +2617,7 @@ FindQuestionFromProgress (
// here, just keep the "Fred" string.
//
EndStr = StrStr (Progress, L"=");
ASSERT (EndStr != NULL);
*EndStr = '\0';
} else {
//
@ -2622,6 +2625,7 @@ FindQuestionFromProgress (
// here, just keep the "OFFSET=0x####&WIDTH=0x####" string.
//
EndStr = StrStr (Progress, L"&VALUE=");
ASSERT (EndStr != NULL);
*EndStr = '\0';
}
@ -4246,9 +4250,8 @@ IsQuestionValueChanged (
}
CopyMem (&Question->HiiValue, &BackUpValue, sizeof (EFI_HII_VALUE));
CopyMem (Question->BufferValue, BackUpBuffer, BufferWidth);
if (BackUpBuffer != NULL) {
CopyMem (Question->BufferValue, BackUpBuffer, BufferWidth);
FreePool (BackUpBuffer);
}