diff options
author | Liming Gao <liming.gao@intel.com> | 2017-12-28 10:55:04 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2017-12-28 13:34:34 +0800 |
commit | a8e786e8b29de5d1c71d3865506c5cc2df9512a2 (patch) | |
tree | c017554caa6793dc347c7c4834bc9f08015e474f /MdeModulePkg | |
parent | 7a3ed289f2b51c34f6b0739ae1b40cad89071d00 (diff) | |
download | edk2-a8e786e8b29de5d1c71d3865506c5cc2df9512a2.tar.gz edk2-a8e786e8b29de5d1c71d3865506c5cc2df9512a2.tar.bz2 edk2-a8e786e8b29de5d1c71d3865506c5cc2df9512a2.zip |
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index 4a2dc8d030..e8f4564e64 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -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.
|