summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2017-12-28 10:55:04 +0800
committerLiming Gao <liming.gao@intel.com>2017-12-28 13:34:34 +0800
commita8e786e8b29de5d1c71d3865506c5cc2df9512a2 (patch)
treec017554caa6793dc347c7c4834bc9f08015e474f /MdeModulePkg
parent7a3ed289f2b51c34f6b0739ae1b40cad89071d00 (diff)
downloadedk2-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.c11
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.