]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Fix the build fail issue on VS2008\VS2010\GCC
authorDandan Bi <dandan.bi@intel.com>
Wed, 24 Feb 2016 01:03:22 +0000 (09:03 +0800)
committerFeng Tian <feng.tian@intel.com>
Thu, 25 Feb 2016 03:06:19 +0000 (11:06 +0800)
This is caused by my last commit,the LoadOption may
not initialize when call FreePool, and after investigation,
find that we can delete the LoadOption variable, this patch
is to fix this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c

index 5665d040889ba406d293577fd96573b55087c7d5..0bd3170872c799c84da9342410cf97fedd6af3f2 100644 (file)
@@ -248,7 +248,6 @@ BOpt_GetBootOptions (
   UINTN                         Index;\r
   UINT16                        BootString[10];\r
   UINT8                         *LoadOptionFromVar;\r
-  UINT8                         *LoadOption;\r
   UINTN                         BootOptionSize;\r
   BOOLEAN                       BootNextFlag;\r
   UINT16                        *BootOrderList;\r
@@ -312,14 +311,6 @@ BOpt_GetBootOptions (
       continue;\r
     }\r
 \r
-    LoadOption = AllocateZeroPool (BootOptionSize);\r
-    if (LoadOption == NULL) {\r
-      continue;\r
-    }\r
-\r
-    CopyMem (LoadOption, LoadOptionFromVar, BootOptionSize);\r
-    FreePool (LoadOptionFromVar);\r
-\r
     if (BootNext != NULL) {\r
       BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);\r
     } else {\r
@@ -331,8 +322,8 @@ BOpt_GetBootOptions (
 \r
     NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
 \r
-    LoadOptionPtr                       = LoadOption;\r
-    LoadOptionEnd                       = LoadOption + BootOptionSize;\r
+    LoadOptionPtr                       = LoadOptionFromVar;\r
+    LoadOptionEnd                       = LoadOptionFromVar + BootOptionSize;\r
 \r
     NewMenuEntry->OptionNumber          = BootOrderList[Index];\r
     NewLoadContext->Deleted             = FALSE;\r
@@ -341,7 +332,7 @@ BOpt_GetBootOptions (
     //\r
     // Is a Legacy Device?\r
     //\r
-    Ptr = (UINT8 *) LoadOption;\r
+    Ptr = (UINT8 *) LoadOptionFromVar;\r
 \r
     //\r
     // Attribute = *(UINT32 *)Ptr;\r
@@ -423,6 +414,7 @@ BOpt_GetBootOptions (
 \r
     InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
     MenuCount++;\r
+    FreePool (LoadOptionFromVar);\r
   }\r
   EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);\r
 \r
@@ -433,7 +425,6 @@ BOpt_GetBootOptions (
     FreePool (BootOrderList);\r
   }\r
 \r
-  FreePool(LoadOption);\r
   BootOptionMenu.MenuNumber = MenuCount;\r
   return EFI_SUCCESS;\r
 }\r
@@ -643,7 +634,6 @@ BOpt_GetDriverOptions (
   UINTN           Index;\r
   UINT16          DriverString[12];\r
   UINT8           *LoadOptionFromVar;\r
-  UINT8           *LoadOption;\r
   UINTN           DriverOptionSize;\r
 \r
   UINT16          *DriverOrderList;\r
@@ -684,13 +674,6 @@ BOpt_GetDriverOptions (
       continue;\r
     }\r
 \r
-    LoadOption = AllocateZeroPool (DriverOptionSize);\r
-    if (LoadOption == NULL) {\r
-      continue;\r
-    }\r
-\r
-    CopyMem (LoadOption, LoadOptionFromVar, DriverOptionSize);\r
-    FreePool (LoadOptionFromVar);\r
 \r
     NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);\r
     if (NULL == NewMenuEntry) {\r
@@ -698,8 +681,8 @@ BOpt_GetDriverOptions (
     }\r
 \r
     NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-    LoadOptionPtr                       = LoadOption;\r
-    LoadOptionEnd                       = LoadOption + DriverOptionSize;\r
+    LoadOptionPtr                       = LoadOptionFromVar;\r
+    LoadOptionEnd                       = LoadOptionFromVar + DriverOptionSize;\r
     NewMenuEntry->OptionNumber          = DriverOrderList[Index];\r
     NewLoadContext->Deleted             = FALSE;\r
     NewLoadContext->IsLegacy            = FALSE;\r
@@ -761,13 +744,14 @@ BOpt_GetDriverOptions (
     }\r
 \r
     InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
+    FreePool (LoadOptionFromVar);\r
 \r
   }\r
 \r
   if (DriverOrderList != NULL) {\r
     FreePool (DriverOrderList);\r
   }\r
-  FreePool(LoadOption);\r
+\r
   DriverOptionMenu.MenuNumber = Index;\r
   return EFI_SUCCESS;\r
 \r