diff options
author | Dandan Bi <dandan.bi@intel.com> | 2017-11-01 16:11:47 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2017-11-03 12:39:45 +0800 |
commit | 631ffb70ebbe78b6e3f342b7ad9ab9b75f8796ae (patch) | |
tree | 6ab75ef9fd10a2754196832293cf6a095ddb927f /BaseTools/Source/C/VfrCompile | |
parent | 2f57de0ae12731fbf3a0cdd4dc1c981e94dc5816 (diff) | |
download | edk2-631ffb70ebbe78b6e3f342b7ad9ab9b75f8796ae.tar.gz edk2-631ffb70ebbe78b6e3f342b7ad9ab9b75f8796ae.tar.bz2 edk2-631ffb70ebbe78b6e3f342b7ad9ab9b75f8796ae.zip |
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 <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/C/VfrCompile')
-rw-r--r-- | BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
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;
|