]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix memory leak in SimpleTextOutput on file.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 23 Dec 2015 05:36:10 +0000 (05:36 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 23 Dec 2015 05:36:10 +0000 (05:36 +0000)
Free 'SimpleTextOut->Mode' buffer before 'SimpleTextOut' is free.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19480 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/ConsoleWrappers.c

index 04a7513a3346fabb272c70c58c74bfe184e7f190..46af141eba99c9de3827f44a1f0689ee7327b417 100644 (file)
@@ -484,7 +484,8 @@ CreateSimpleTextOutOnFile(
     *HandleLocation = ProtocolToReturn->TheHandle;\r
     return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);\r
   } else {\r
-    FreePool(ProtocolToReturn);\r
+    SHELL_FREE_NON_NULL(ProtocolToReturn->SimpleTextOut.Mode);\r
+    SHELL_FREE_NON_NULL(ProtocolToReturn);\r
     return (NULL);\r
   }\r
 }\r
@@ -511,6 +512,7 @@ CloseSimpleTextOutOnFile(
     ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle, \r
     &gEfiSimpleTextOutProtocolGuid, \r
     &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));\r
+  FreePool(SimpleTextOut->Mode);\r
   FreePool(SimpleTextOut);\r
   return (Status);\r
 }\r