]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/VfrCompile: Add check to avoid using NULL pointer
authorDandan Bi <dandan.bi@intel.com>
Wed, 1 Nov 2017 08:11:47 +0000 (16:11 +0800)
committerHao Wu <hao.a.wu@intel.com>
Fri, 3 Nov 2017 04:39:45 +0000 (12:39 +0800)
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>
BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp

index b00a926adeb549f465bcf83544dc39fefb50c222..0fe14b0d29215213c48ee38b27e9a0c3efa40130 100644 (file)
@@ -615,9 +615,13 @@ CVfrVarDataTypeDB::DataTypeHasBitField (
   SVfrDataField       *pTmp;\r
 \r
   GetDataType (TypeName, &pType);\r
+\r
+  if (pType == NULL){\r
+    return FALSE;\r
+  }\r
   for (pTmp = pType->mMembers; pTmp!= NULL; pTmp = pTmp->mNext) {\r
     if (pTmp->mIsBitField) {\r
-       return TRUE;\r
+      return TRUE;\r
     }\r
   }\r
   return FALSE;\r
@@ -648,7 +652,7 @@ CVfrVarDataTypeDB::IsThisBitField (
     CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);\r
     pType  = pField->mFieldType;\r
   }\r
-  if (pField->mIsBitField) {\r
+  if (pField != NULL && pField->mIsBitField) {\r
     return TRUE;\r
   } else {\r
     return FALSE;\r