]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UefiBootManagerLib: Fix small LoadOptionToVariable leak
authorThomas Palmer <thomas.palmer@hpe.com>
Tue, 3 Jul 2018 16:40:52 +0000 (00:40 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 6 Jul 2018 07:38:15 +0000 (15:38 +0800)
After calling SetVariable, the allocated memory in Variable should be
freed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c

index ff0c65a2efc6cba4f77eaff354f3a7541bed6210..7bf96646c690e2606fe77b7c8333855fe0bc8a2c 100644 (file)
@@ -2,7 +2,7 @@
   Load option library functions which relate with creating and processing load options.\r
 \r
 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
+(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -250,13 +250,16 @@ structure.
     VariableAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;\r
   }\r
 \r
-  return gRT->SetVariable (\r
-                OptionName,\r
-                &gEfiGlobalVariableGuid,\r
-                VariableAttributes,\r
-                VariableSize,\r
-                Variable\r
-                );\r
+  Status = gRT->SetVariable (\r
+                  OptionName,\r
+                  &gEfiGlobalVariableGuid,\r
+                  VariableAttributes,\r
+                  VariableSize,\r
+                  Variable\r
+                  );\r
+  FreePool (Variable);\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r