]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Fix memory leak in ShellProtocol.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 23 Dec 2015 05:44:19 +0000 (05:44 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 23 Dec 2015 05:44:19 +0000 (05:44 +0000)
1. Close unused file handle.
2. Free the local allocated buffer function returned.

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

ShellPkg/Application/Shell/ShellProtocol.c

index def3bd35c208e6a7a669a744e55db1cd338231ee..2ddb64d8c7d69a18cd5730925f59ebd7b6743ce7 100644 (file)
@@ -1361,6 +1361,7 @@ EfiShellDeleteFileByName(
   //\r
   // now delete the file\r
   //\r
+  ShellFileHandleRemove(FileHandle);\r
   return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));\r
 }\r
 \r
@@ -2338,6 +2339,8 @@ ShellSearchHandle(
               // recurse with the next part of the pattern\r
               //\r
               Status = ShellSearchHandle(NextFilePatternStart, UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);\r
+              EfiShellClose(ShellInfoNode->Handle);\r
+              ShellInfoNode->Handle = NULL;\r
             }\r
           } else if (!EFI_ERROR(Status)) {\r
             //\r
@@ -2456,6 +2459,7 @@ EfiShellFindFiles(
             ; PatternCurrentLocation++);\r
         PatternCurrentLocation++;\r
         Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);\r
+        EfiShellClose(RootFileHandle);\r
       }\r
       FreePool(RootDevicePath);\r
     }\r
@@ -3260,6 +3264,7 @@ EfiShellGetAlias(
 \r
     if (Volatile == NULL) {\r
       GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);\r
+      FreePool(AliasLower);\r
       return (AddBufferToFreeList(AliasVal));\r
     }\r
     RetSize = 0;\r
@@ -3273,6 +3278,7 @@ EfiShellGetAlias(
       if (RetVal != NULL) {\r
         FreePool(RetVal);\r
       }\r
+      FreePool(AliasLower);\r
       return (NULL);\r
     }\r
     if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {\r