Question value are stored in one specified storage, but the Data type
of the storage or the field in the Data type may be NULL sometime,
so we need to add check before using these 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.d...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp 
b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index b00a926..0fe14b0 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -613,13 +613,17 @@ CVfrVarDataTypeDB::DataTypeHasBitField (
 {
   SVfrDataType        *pType  = NULL;
   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;
 }
 
@@ -646,11 +650,11 @@ CVfrVarDataTypeDB::IsThisBitField (
   while (*VarStr != '\0') {
     CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), 
VFR_RETURN_SUCCESS);
     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;
   }
 }
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to