From: Dandan Bi Date: Wed, 1 Nov 2017 08:11:47 +0000 (+0800) Subject: BaseTools/VfrCompile: Add check to avoid using NULL pointer X-Git-Tag: edk2-stable201903~3147 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=631ffb70ebbe78b6e3f342b7ad9ab9b75f8796ae;hp=2f57de0ae12731fbf3a0cdd4dc1c981e94dc5816 BaseTools/VfrCompile: Add check to avoid using NULL pointer Question value are stored in one specified storage, but the Data type of the storage is not specified or there is no sub fields in the Data type sometimes, so we need to add check before using related pointers. Here list some NULL cases: (1)For an efivastore which doesn't specify a data structure or a data type(UINT8,UINT16...)as the storage, just has VarName and VarSize instead, we can not get its data type before parsing its VarSize. (2)For efivastore which just specifies the data type(UINT8,UINT16...) not a structure as the storage,this data type doesn't have sub-fields. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index b00a926ade..0fe14b0d29 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -615,9 +615,13 @@ CVfrVarDataTypeDB::DataTypeHasBitField ( SVfrDataField *pTmp; GetDataType (TypeName, &pType); + + if (pType == NULL){ + return FALSE; + } for (pTmp = pType->mMembers; pTmp!= NULL; pTmp = pTmp->mNext) { if (pTmp->mIsBitField) { - return TRUE; + return TRUE; } } return FALSE; @@ -648,7 +652,7 @@ CVfrVarDataTypeDB::IsThisBitField ( CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS); pType = pField->mFieldType; } - if (pField->mIsBitField) { + if (pField != NULL && pField->mIsBitField) { return TRUE; } else { return FALSE;