summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell
diff options
context:
space:
mode:
authorYao Jiewen <Jiewen.Yao@intel.com>2015-12-25 02:15:44 +0000
committerhwu1225 <hwu1225@Edk2>2015-12-25 02:15:44 +0000
commitaf71a010d1753bf4c84a41d1d201bc7409cdf350 (patch)
treecc5ff728b824a67604b36b89557ad234b321fc1b /ShellPkg/Application/Shell
parent0dd73893d00a5d7be3d22b3ff318781942d5052e (diff)
downloadedk2-platforms-af71a010d1753bf4c84a41d1d201bc7409cdf350.tar.xz
ShellPkg: Fix memory leak in function 'EfiShellSetCurDir' and 'EfiShellSetMap'.
(Sync patch r19529 from main trunk.) Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yao Jiewen <Jiewen.Yao@intel.com> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19541 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell')
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index a6bf9c29b4..22d398757f 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -185,6 +185,9 @@ EfiShellSetMap(
){
if (StringNoCaseCompare(&MapListNode->MapName, &Mapping) == 0) {
RemoveEntryList(&MapListNode->Link);
+ SHELL_FREE_NON_NULL(MapListNode->DevicePath);
+ SHELL_FREE_NON_NULL(MapListNode->MapName);
+ SHELL_FREE_NON_NULL(MapListNode->CurrentDirectoryPath);
FreePool(MapListNode);
return (EFI_SUCCESS);
}
@@ -2951,6 +2954,8 @@ EfiShellSetCurDir(
}
if (MapListItem == NULL) {
+ FreePool (DirectoryName);
+ SHELL_FREE_NON_NULL(MapName);
return (EFI_NOT_FOUND);
}
@@ -2967,6 +2972,7 @@ EfiShellSetCurDir(
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName+StrLen(MapName), 0);
}
+ FreePool (MapName);
} else {
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
@@ -2982,6 +2988,7 @@ EfiShellSetCurDir(
// cant have a mapping in the directory...
//
if (StrStr(DirectoryName, L":") != NULL) {
+ FreePool (DirectoryName);
return (EFI_INVALID_PARAMETER);
}
//
@@ -2989,6 +2996,7 @@ EfiShellSetCurDir(
//
MapListItem = ShellCommandFindMapItem(FileSystem);
if (MapListItem == NULL) {
+ FreePool (DirectoryName);
return (EFI_INVALID_PARAMETER);
}
// gShellCurDir = MapListItem;
@@ -3013,6 +3021,7 @@ EfiShellSetCurDir(
}
}
}
+ FreePool (DirectoryName);
//
// if updated the current directory then update the environment variable
//