1. Close unused file handle.
2. Free the local allocated buffer function returned.

Cc: Jaben Carsey <[email protected]>
Cc: Ruiyu Ni <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>
---
 ShellPkg/Application/Shell/ShellProtocol.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ShellPkg/Application/Shell/ShellProtocol.c 
b/ShellPkg/Application/Shell/ShellProtocol.c
index def3bd3..6d5fc1f 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -1361,6 +1361,7 @@ EfiShellDeleteFileByName(
   //
   // now delete the file
   //
+  ShellFileHandleRemove(FileHandle);
   return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));
 }
 
@@ -2338,6 +2339,7 @@ ShellSearchHandle(
               // recurse with the next part of the pattern
               //
               Status = ShellSearchHandle(NextFilePatternStart, 
UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
+              EfiShellClose(ShellInfoNode->Handle);
             }
           } else if (!EFI_ERROR(Status)) {
             //
@@ -2456,6 +2458,7 @@ EfiShellFindFiles(
             ; PatternCurrentLocation++);
         PatternCurrentLocation++;
         Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, 
RootFileHandle, FileList, NULL, MapName);
+        EfiShellClose(RootFileHandle);
       }
       FreePool(RootDevicePath);
     }
@@ -3260,6 +3263,7 @@ EfiShellGetAlias(
 
     if (Volatile == NULL) {
       GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
+      FreePool(AliasLower);
       return (AddBufferToFreeList(AliasVal));
     }
     RetSize = 0;
@@ -3273,6 +3277,7 @@ EfiShellGetAlias(
       if (RetVal != NULL) {
         FreePool(RetVal);
       }
+      FreePool(AliasLower);
       return (NULL);
     }
     if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to