From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 08978222447DF for ; Tue, 26 Dec 2017 18:26:29 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 18:31:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,462,1508828400"; d="scan'208";a="16775752" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.15]) by fmsmga001.fm.intel.com with ESMTP; 26 Dec 2017 18:31:24 -0800 From: Liming Gao To: edk2-devel@lists.01.org Cc: Star Zeng Date: Wed, 27 Dec 2017 10:31:19 +0800 Message-Id: <1514341879-10544-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [Patch] MdeModulePkg HiiDataBase: Fix the potential NULL pointer reference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Dec 2017 02:26:30 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Cc: Star Zeng --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index c10134b8e6..e062094f79 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -845,7 +845,7 @@ UpdateDefaultSettingInFormPackage ( // EfiVarStoreList = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList); if (EfiVarStoreList == NULL) { - break; + goto Done; } EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER; } @@ -874,7 +874,7 @@ UpdateDefaultSettingInFormPackage ( // DefaultIdList = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList); if (DefaultIdList == NULL) { - break; + goto Done; } DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER; } @@ -1046,8 +1046,10 @@ UpdateDefaultSettingInFormPackage ( } Done: - for (Index = 0; Index < EfiVarStoreNumber; Index ++) { - FreePool (EfiVarStoreList [Index]); + if (EfiVarStoreList != NULL) { + for (Index = 0; Index < EfiVarStoreNumber; Index ++) { + FreePool (EfiVarStoreList [Index]); + } } return; } -- 2.11.0.windows.1