]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
MdeModulePkg HiiDataBase: Fix the potential NULL pointer reference
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / Database.c
index c10134b8e67712fd2fe8279254ecb4ccfdff0127..4a2dc8d0304399810344f05b5d246a57f5f3d66b 100644 (file)
@@ -845,7 +845,7 @@ UpdateDefaultSettingInFormPackage (
         //\r
         EfiVarStoreList   = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList);\r
         if (EfiVarStoreList == NULL) {\r
-          break;\r
+          goto Done;\r
         }\r
         EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER;\r
       }\r
@@ -874,7 +874,7 @@ UpdateDefaultSettingInFormPackage (
         //\r
         DefaultIdList   = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList);\r
         if (DefaultIdList == NULL) {\r
-          break;\r
+          goto Done;\r
         }\r
         DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER;\r
       }\r
@@ -1046,8 +1046,10 @@ UpdateDefaultSettingInFormPackage (
   }\r
 \r
 Done:\r
-  for (Index = 0; Index < EfiVarStoreNumber; Index ++) {\r
-    FreePool (EfiVarStoreList [Index]);\r
+  if (EfiVarStoreList != NULL) {\r
+    for (Index = 0; Index < EfiVarStoreNumber; Index ++) {\r
+      FreePool (EfiVarStoreList [Index]);\r
+    }\r
   }\r
   return;\r
 }\r