Revision: 19481
          http://sourceforge.net/p/edk2/code/19481
Author:   shenshushi
Date:     2015-12-23 05:44:19 +0000 (Wed, 23 Dec 2015)
Log Message:
-----------
ShellPkg: Fix memory leak in ShellProtocol.

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 <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Application/Shell/ShellProtocol.c

Modified: trunk/edk2/ShellPkg/Application/Shell/ShellProtocol.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/ShellProtocol.c       2015-12-23 
05:36:10 UTC (rev 19480)
+++ trunk/edk2/ShellPkg/Application/Shell/ShellProtocol.c       2015-12-23 
05:44:19 UTC (rev 19481)
@@ -1361,6 +1361,7 @@
   //
   // now delete the file
   //
+  ShellFileHandleRemove(FileHandle);
   return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));
 }
 
@@ -2338,6 +2339,8 @@
               // recurse with the next part of the pattern
               //
               Status = ShellSearchHandle(NextFilePatternStart, 
UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
+              EfiShellClose(ShellInfoNode->Handle);
+              ShellInfoNode->Handle = NULL;
             }
           } else if (!EFI_ERROR(Status)) {
             //
@@ -2456,6 +2459,7 @@
             ; PatternCurrentLocation++);
         PatternCurrentLocation++;
         Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, 
RootFileHandle, FileList, NULL, MapName);
+        EfiShellClose(RootFileHandle);
       }
       FreePool(RootDevicePath);
     }
@@ -3260,6 +3264,7 @@
 
     if (Volatile == NULL) {
       GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
+      FreePool(AliasLower);
       return (AddBufferToFreeList(AliasVal));
     }
     RetSize = 0;
@@ -3273,6 +3278,7 @@
       if (RetVal != NULL) {
         FreePool(RetVal);
       }
+      FreePool(AliasLower);
       return (NULL);
     }
     if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to