From a8e786e8b29de5d1c71d3865506c5cc2df9512a2 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 28 Dec 2017 10:55:04 +0800 Subject: MdeModulePkg HiiDataBase: Fix the potential NULL pointer access Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Reviewed-by: Star Zeng --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index 4a2dc8d..e8f4564 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. -- cgit v1.1