]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg HiiDataBaseDxe: Add the check for the memory allocation return
authorLiming Gao <liming.gao@intel.com>
Tue, 26 Dec 2017 08:36:11 +0000 (16:36 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 26 Dec 2017 09:46:31 +0000 (17:46 +0800)
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Universal/HiiDatabaseDxe/Database.c

index 7441c1906ddcdb8ad5fd54c8e3f16764cc39d102..c10134b8e67712fd2fe8279254ecb4ccfdff0127 100644 (file)
@@ -844,6 +844,9 @@ UpdateDefaultSettingInFormPackage (
         // Reallocate EFI VarStore Buffer\r
         //\r
         EfiVarStoreList   = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList);\r
         // Reallocate EFI VarStore Buffer\r
         //\r
         EfiVarStoreList   = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList);\r
+        if (EfiVarStoreList == NULL) {\r
+          break;\r
+        }\r
         EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER;\r
       }\r
       IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
         EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER;\r
       }\r
       IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;\r
@@ -851,6 +854,9 @@ UpdateDefaultSettingInFormPackage (
       // Convert VarStore Name from ASCII string to Unicode string.\r
       //\r
       EfiVarStoreList [EfiVarStoreNumber] = AllocatePool (IfrEfiVarStore->Header.Length + AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name));\r
       // Convert VarStore Name from ASCII string to Unicode string.\r
       //\r
       EfiVarStoreList [EfiVarStoreNumber] = AllocatePool (IfrEfiVarStore->Header.Length + AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name));\r
+      if (EfiVarStoreList [EfiVarStoreNumber] == NULL) {\r
+        break;\r
+      }\r
       CopyMem (EfiVarStoreList [EfiVarStoreNumber], IfrEfiVarStore, IfrEfiVarStore->Header.Length);\r
       AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 *) &(EfiVarStoreList [EfiVarStoreNumber]->Name[0]), AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
       Status = FindQuestionDefaultSetting (EFI_HII_DEFAULT_CLASS_STANDARD, EfiVarStoreList[EfiVarStoreNumber], &VarStoreQuestionHeader, NULL, IfrEfiVarStore->Size, FALSE);\r
       CopyMem (EfiVarStoreList [EfiVarStoreNumber], IfrEfiVarStore, IfrEfiVarStore->Header.Length);\r
       AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 *) &(EfiVarStoreList [EfiVarStoreNumber]->Name[0]), AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16));\r
       Status = FindQuestionDefaultSetting (EFI_HII_DEFAULT_CLASS_STANDARD, EfiVarStoreList[EfiVarStoreNumber], &VarStoreQuestionHeader, NULL, IfrEfiVarStore->Size, FALSE);\r
@@ -867,6 +873,9 @@ UpdateDefaultSettingInFormPackage (
         // Reallocate DefaultIdNumber\r
         //\r
         DefaultIdList   = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList);\r
         // Reallocate DefaultIdNumber\r
         //\r
         DefaultIdList   = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList);\r
+        if (DefaultIdList == NULL) {\r
+          break;\r
+        }\r
         DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER;\r
       }\r
       DefaultIdList[DefaultIdNumber ++] = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultId;\r
         DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER;\r
       }\r
       DefaultIdList[DefaultIdNumber ++] = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultId;\r