MdeModulePkg HiiDataBase: Fix the potential NULL pointer access

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Liming Gao 2017-12-28 10:55:04 +08:00
parent 7a3ed289f2
commit a8e786e8b2
1 changed files with 8 additions and 3 deletions

View File

@ -721,9 +721,14 @@ FindQuestionDefaultSetting (
VariableStorage = NULL;
}
Entry = AllocatePool (sizeof (VARSTORAGE_DEFAULT_DATA));
Entry->DefaultId = DefaultId;
Entry->VariableStorage = VariableStorage;
InsertTailList (&gVarStorageList, &Entry->Entry);
if (Entry != NULL) {
Entry->DefaultId = DefaultId;
Entry->VariableStorage = VariableStorage;
InsertTailList (&gVarStorageList, &Entry->Entry);
} else if (VariableStorage != NULL) {
FreePool (VariableStorage);
VariableStorage = NULL;
}
}
//
// The matched variable storage is not found.