Add the missing check for NULL pointer before use it.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10116 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2010-02-27 09:04:11 +00:00
parent 3978f5d92b
commit 771ececd12
7 changed files with 23 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Parser for IFR binary encoding. Parser for IFR binary encoding.
Copyright (c) 2008, Intel Corporation Copyright (c) 2008 - 2010, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -209,6 +209,7 @@ CreateStorage (
FORMSET_STORAGE *Storage; FORMSET_STORAGE *Storage;
Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE)); Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
ASSERT (Storage != NULL);
Storage->Signature = FORMSET_STORAGE_SIGNATURE; Storage->Signature = FORMSET_STORAGE_SIGNATURE;
InsertTailList (&FormSet->StorageListHead, &Storage->Link); InsertTailList (&FormSet->StorageListHead, &Storage->Link);
@ -586,6 +587,7 @@ ParseOpCodes (
// Create a new Form for this FormSet // Create a new Form for this FormSet
// //
CurrentForm = AllocateZeroPool (sizeof (FORM_BROWSER_FORM)); CurrentForm = AllocateZeroPool (sizeof (FORM_BROWSER_FORM));
ASSERT (CurrentForm != NULL);
CurrentForm->Signature = FORM_BROWSER_FORM_SIGNATURE; CurrentForm->Signature = FORM_BROWSER_FORM_SIGNATURE;
InitializeListHead (&CurrentForm->StatementListHead); InitializeListHead (&CurrentForm->StatementListHead);
@ -701,6 +703,7 @@ ParseOpCodes (
// //
case EFI_IFR_DEFAULTSTORE_OP: case EFI_IFR_DEFAULTSTORE_OP:
DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE)); DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));
ASSERT (DefaultStore != NULL);
DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE; DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;
CopyMem (&DefaultStore->DefaultId, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId, sizeof (UINT16)); CopyMem (&DefaultStore->DefaultId, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId, sizeof (UINT16));
@ -917,6 +920,7 @@ ParseOpCodes (
// A Question may have more than one Default value which have different default types. // A Question may have more than one Default value which have different default types.
// //
CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT)); CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT));
ASSERT (CurrentDefault != NULL);
CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE; CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE;
CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type; CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;
@ -940,6 +944,7 @@ ParseOpCodes (
// It create a selection for use in current Question. // It create a selection for use in current Question.
// //
CurrentOption = AllocateZeroPool (sizeof (QUESTION_OPTION)); CurrentOption = AllocateZeroPool (sizeof (QUESTION_OPTION));
ASSERT (CurrentOption != NULL);
CurrentOption->Signature = QUESTION_OPTION_SIGNATURE; CurrentOption->Signature = QUESTION_OPTION_SIGNATURE;
CurrentOption->Flags = ((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags; CurrentOption->Flags = ((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags;

View File

@ -7,7 +7,7 @@ these two conditions are true:
1) Framework module consuming FV is present 1) Framework module consuming FV is present
2) And the platform only produces FV2 2) And the platform only produces FV2
Copyright (c) 2006 - 2008 Intel Corporation. <BR> Copyright (c) 2006 - 2010 Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -597,6 +597,7 @@ FvWriteFile (
FirmwareVolume2 = Private->FirmwareVolume2; FirmwareVolume2 = Private->FirmwareVolume2;
PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData); PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData);
ASSERT (PiFileData != NULL);
// //
// Framework Spec assume firmware files are Memory-Mapped. // Framework Spec assume firmware files are Memory-Mapped.

View File

@ -3192,7 +3192,7 @@ Exit:
@param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL @param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
instance. instance.
@param ConfigResp A null-terminated Unicode string in <ConfigResp> @param ConfigResp A null-terminated Unicode string in <ConfigResp>
format. It can be ConfigAltResp format string. format.
@param Block A possibly null array of bytes representing the @param Block A possibly null array of bytes representing the
current block. Only bytes referenced in the current block. Only bytes referenced in the
ConfigResp string in the block are modified. If ConfigResp string in the block are modified. If
@ -3415,7 +3415,7 @@ Exit:
@param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL @param This A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
instance. instance.
@param Configuration A null-terminated Unicode string in @param Configuration A null-terminated Unicode string in
<MultiConfigAltResp> format. It is <ConfigAltResp> format. <MultiConfigAltResp> format.
@param Guid A pointer to the GUID value to search for in the @param Guid A pointer to the GUID value to search for in the
routing portion of the ConfigResp string when routing portion of the ConfigResp string when
retrieving the requested data. If Guid is NULL, retrieving the requested data. If Guid is NULL,

View File

@ -1729,6 +1729,7 @@ EvaluateExpression (
// //
Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr); Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ASSERT (StrPtr != NULL);
TempLength = StrLen (StrPtr); TempLength = StrLen (StrPtr);
if (OpCode->ValueWidth >= ((TempLength + 1) / 2)) { if (OpCode->ValueWidth >= ((TempLength + 1) / 2)) {
Value->Type = OpCode->ValueType; Value->Type = OpCode->ValueType;
@ -1740,7 +1741,7 @@ EvaluateExpression (
if ((Index & 1) == 0) { if ((Index & 1) == 0) {
TempBuffer [Index/2] = DigitUint8; TempBuffer [Index/2] = DigitUint8;
} else { } else {
TempBuffer [Index/2] = (UINT8) ((DigitUint8 << 4) + TempStr [Index/2]); TempBuffer [Index/2] = (UINT8) ((DigitUint8 << 4) + TempBuffer [Index/2]);
} }
} }
} }

View File

@ -1174,6 +1174,7 @@ ParseOpCodes (
// //
if (CurrentExpression == NULL && MapScopeDepth > 0) { if (CurrentExpression == NULL && MapScopeDepth > 0) {
CurrentExpression = CreateExpression (CurrentForm); CurrentExpression = CreateExpression (CurrentForm);
ASSERT (MapExpressionList != NULL);
InsertTailList (MapExpressionList, &CurrentExpression->Link); InsertTailList (MapExpressionList, &CurrentExpression->Link);
if (Scope == 0) { if (Scope == 0) {
SingleOpCodeExpression = TRUE; SingleOpCodeExpression = TRUE;
@ -2120,6 +2121,7 @@ ParseOpCodes (
// //
Status = PopCurrentExpression ((VOID **) &CurrentExpression); Status = PopCurrentExpression ((VOID **) &CurrentExpression);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
ASSERT (MapScopeDepth > 0);
MapScopeDepth --; MapScopeDepth --;
break; break;

View File

@ -109,6 +109,8 @@ NewStrCat (
hit, then 2 Unicode character will consume an output storage hit, then 2 Unicode character will consume an output storage
space with size of CHAR16 till a NARROW_CHAR is hit. space with size of CHAR16 till a NARROW_CHAR is hit.
If String is NULL, then ASSERT ().
@param String The input string to be counted. @param String The input string to be counted.
@return Storage space for the input string. @return Storage space for the input string.
@ -123,6 +125,11 @@ GetStringWidth (
UINTN Count; UINTN Count;
UINTN IncrementValue; UINTN IncrementValue;
ASSERT (String != NULL);
if (String == NULL) {
return 0;
}
Index = 0; Index = 0;
Count = 0; Count = 0;
IncrementValue = 1; IncrementValue = 1;

View File

@ -623,6 +623,8 @@ ClearLines (
hit, then 2 Unicode character will consume an output storage hit, then 2 Unicode character will consume an output storage
space with size of CHAR16 till a NARROW_CHAR is hit. space with size of CHAR16 till a NARROW_CHAR is hit.
If String is NULL, then ASSERT ().
@param String The input string to be counted. @param String The input string to be counted.
@return Storage space for the input string. @return Storage space for the input string.