Add in ASSERT to check out-of-bound and possible dereference of NULL pointers.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7391 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12
2009-02-02 07:18:59 +00:00
parent af58e37731
commit bc166db311
6 changed files with 32 additions and 6 deletions

View File

@@ -1059,7 +1059,6 @@ ParseOpCodes (
//
// Evaluate DisableIf expression
//
ASSERT (CurrentExpression != NULL);
Status = EvaluateExpression (FormSet, CurrentForm, CurrentExpression);
if (EFI_ERROR (Status)) {
return Status;
@@ -1193,6 +1192,8 @@ ParseOpCodes (
//
case EFI_IFR_SUBTITLE_OP:
CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_SUBTITLE *) OpCodeData)->Flags;
if (Scope != 0) {
@@ -1202,6 +1203,7 @@ ParseOpCodes (
case EFI_IFR_TEXT_OP:
CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
ASSERT (CurrentStatement != NULL);
CopyMem (&CurrentStatement->TextTwo, &((EFI_IFR_TEXT *) OpCodeData)->TextTwo, sizeof (EFI_STRING_ID));
break;
@@ -1211,6 +1213,7 @@ ParseOpCodes (
//
case EFI_IFR_ACTION_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
ASSERT (CurrentStatement != NULL);
if (OpCodeLength == sizeof (EFI_IFR_ACTION_1)) {
//
@@ -1548,6 +1551,12 @@ ParseOpCodes (
//
// If used for a question, then the question will be read-only
//
//
// Make sure CurrentStatement is not NULL.
// If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
// file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
//
ASSERT (CurrentStatement != NULL);
CurrentStatement->ValueExpression = CurrentExpression;
}
break;
@@ -1585,6 +1594,12 @@ ParseOpCodes (
break;
default:
//
// Make sure CurrentStatement is not NULL.
// If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
// file is wrongly generated by tools such as VFR Compiler.
//
ASSERT (CurrentStatement != NULL);
ImageId = &CurrentStatement->ImageId;
break;
}