Revision: 19541
http://sourceforge.net/p/edk2/code/19541
Author: hwu1225
Date: 2015-12-25 02:15:44 +0000 (Fri, 25 Dec 2015)
Log Message:
-----------
ShellPkg: Fix memory leak in function 'EfiShellSetCurDir' and 'EfiShellSetMap'.
(Sync patch r19529 from main trunk.)
Cc: Ruiyu Ni <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yao Jiewen <[email protected]>
Reviewed-by: Qiu Shumin <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/19529
Modified Paths:
--------------
branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c
Modified: branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c
===================================================================
--- branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-25
02:15:16 UTC (rev 19540)
+++ branches/UDK2015/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-25
02:15:44 UTC (rev 19541)
@@ -185,6 +185,9 @@
){
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 @@
}
if (MapListItem == NULL) {
+ FreePool (DirectoryName);
+ SHELL_FREE_NON_NULL(MapName);
return (EFI_NOT_FOUND);
}
@@ -2967,6 +2972,7 @@
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 @@
// cant have a mapping in the directory...
//
if (StrStr(DirectoryName, L":") != NULL) {
+ FreePool (DirectoryName);
return (EFI_INVALID_PARAMETER);
}
//
@@ -2989,6 +2996,7 @@
//
MapListItem = ShellCommandFindMapItem(FileSystem);
if (MapListItem == NULL) {
+ FreePool (DirectoryName);
return (EFI_INVALID_PARAMETER);
}
// gShellCurDir = MapListItem;
@@ -3013,6 +3021,7 @@
}
}
}
+ FreePool (DirectoryName);
//
// if updated the current directory then update the environment variable
//
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits