]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModulePkg BdsLib: Fix potential memory leak when calling BdsLibGetVaria...
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>
Fri, 1 Aug 2014 02:45:45 +0000 (02:45 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Aug 2014 02:45:45 +0000 (02:45 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni<ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15732 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c

index 8451d3434ab65fb58b6c32b83826344785ba720d..8acdad8f532113eee8369aaee51ac09dac401b18 100644 (file)
@@ -3570,6 +3570,8 @@ BdsLibBootNext (
     ASSERT (BootOption != NULL);\r
     BdsLibConnectDevicePath (BootOption->DevicePath);\r
     BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
     ASSERT (BootOption != NULL);\r
     BdsLibConnectDevicePath (BootOption->DevicePath);\r
     BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
+    FreePool(BootOption);\r
+    FreePool(BootNext);\r
   }\r
 \r
 }\r
   }\r
 \r
 }\r
index 7b3f2050ae40f183756103d580e31d1e13e63051..dbb132226f1374108b9c7e92f986758309727c10 100644 (file)
@@ -168,6 +168,7 @@ BdsLibGetFreeOptionNumber (
     if (OptionBuffer == NULL) {\r
       break;\r
     }\r
     if (OptionBuffer == NULL) {\r
       break;\r
     }\r
+    FreePool(OptionBuffer);\r
     Index++;\r
   } while (TRUE);\r
 \r
     Index++;\r
   } while (TRUE);\r
 \r
@@ -265,6 +266,7 @@ BdsLibRegisterNewOption (
     // Validate the variable.\r
     //\r
     if (!ValidateOption(OptionPtr, OptionSize)) {\r
     // Validate the variable.\r
     //\r
     if (!ValidateOption(OptionPtr, OptionSize)) {\r
+      FreePool(OptionPtr);\r
       continue;\r
     }\r
 \r
       continue;\r
     }\r
 \r
@@ -626,6 +628,7 @@ BdsLibVariableToOption (
   // Validate Boot#### variable data.\r
   //\r
   if (!ValidateOption(Variable, VariableSize)) {\r
   // Validate Boot#### variable data.\r
   //\r
   if (!ValidateOption(Variable, VariableSize)) {\r
+    FreePool (Variable);\r
     return NULL;\r
   }\r
 \r
     return NULL;\r
   }\r
 \r
@@ -674,6 +677,7 @@ BdsLibVariableToOption (
   //\r
   Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));\r
   if (Option == NULL) {\r
   //\r
   Option = AllocateZeroPool (sizeof (BDS_COMMON_OPTION));\r
   if (Option == NULL) {\r
+    FreePool (Variable);\r
     return NULL;\r
   }\r
 \r
     return NULL;\r
   }\r
 \r