summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Application
diff options
context:
space:
mode:
authorQiu Shumin <shumin.qiu@intel.com>2015-12-23 05:44:19 +0000
committershenshushi <shenshushi@Edk2>2015-12-23 05:44:19 +0000
commit06e5ae774ecf716216b325c432e70f7368c0d694 (patch)
treed0d91319699cc44ee1621bd83c6878a1ced6d99f /ShellPkg/Application
parent5772d0f540cd770dccb37c8742f173c57109bea7 (diff)
downloadedk2-06e5ae774ecf716216b325c432e70f7368c0d694.tar.gz
edk2-06e5ae774ecf716216b325c432e70f7368c0d694.tar.bz2
edk2-06e5ae774ecf716216b325c432e70f7368c0d694.zip
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 <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
Diffstat (limited to 'ShellPkg/Application')
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index def3bd35c2..2ddb64d8c7 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,8 @@ ShellSearchHandle(
// 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 @@ EfiShellFindFiles(
; PatternCurrentLocation++);
PatternCurrentLocation++;
Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);
+ EfiShellClose(RootFileHandle);
}
FreePool(RootDevicePath);
}
@@ -3260,6 +3264,7 @@ EfiShellGetAlias(
if (Volatile == NULL) {
GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
+ FreePool(AliasLower);
return (AddBufferToFreeList(AliasVal));
}
RetSize = 0;
@@ -3273,6 +3278,7 @@ EfiShellGetAlias(
if (RetVal != NULL) {
FreePool(RetVal);
}
+ FreePool(AliasLower);
return (NULL);
}
if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {