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 3904A222CB332 for ; Tue, 26 Dec 2017 00:31:20 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 00:36:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,459,1508828400"; d="scan'208";a="5294103" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.15]) by fmsmga008.fm.intel.com with ESMTP; 26 Dec 2017 00:36:13 -0800 From: Liming Gao To: edk2-devel@lists.01.org Cc: Star Zeng Date: Tue, 26 Dec 2017 16:36:11 +0800 Message-Id: <1514277371-11760-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [Patch] MdeModulePkg HiiDataBaseDxe: Add the check for the memory allocation return 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: Tue, 26 Dec 2017 08:31:20 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Cc: Star Zeng --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index 7441c19..c10134b 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -844,6 +844,9 @@ UpdateDefaultSettingInFormPackage ( // Reallocate EFI VarStore Buffer // EfiVarStoreList = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList); + if (EfiVarStoreList == NULL) { + break; + } EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER; } IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; @@ -851,6 +854,9 @@ UpdateDefaultSettingInFormPackage ( // Convert VarStore Name from ASCII string to Unicode string. // EfiVarStoreList [EfiVarStoreNumber] = AllocatePool (IfrEfiVarStore->Header.Length + AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name)); + if (EfiVarStoreList [EfiVarStoreNumber] == NULL) { + break; + } CopyMem (EfiVarStoreList [EfiVarStoreNumber], IfrEfiVarStore, IfrEfiVarStore->Header.Length); AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 *) &(EfiVarStoreList [EfiVarStoreNumber]->Name[0]), AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16)); Status = FindQuestionDefaultSetting (EFI_HII_DEFAULT_CLASS_STANDARD, EfiVarStoreList[EfiVarStoreNumber], &VarStoreQuestionHeader, NULL, IfrEfiVarStore->Size, FALSE); @@ -867,6 +873,9 @@ UpdateDefaultSettingInFormPackage ( // Reallocate DefaultIdNumber // DefaultIdList = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList); + if (DefaultIdList == NULL) { + break; + } DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER; } DefaultIdList[DefaultIdNumber ++] = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultId; -- 2.8.0.windows.1