]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
MdeModulePkg HiiDataBaseDxe: Add the check for the memory allocation return
[mirror_edk2.git] / 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
+        if (EfiVarStoreList == NULL) {\r
+          break;\r
+        }\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
+      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
@@ -867,6 +873,9 @@ UpdateDefaultSettingInFormPackage (
         // 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