Revision: 19529
http://sourceforge.net/p/edk2/code/19529
Author: shenshushi
Date: 2015-12-25 01:52:56 +0000 (Fri, 25 Dec 2015)
Log Message:
-----------
ShellPkg: Fix memory leak in function 'EfiShellSetCurDir' and 'EfiShellSetMap'.
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]>
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-25
01:46:02 UTC (rev 19528)
+++ trunk/edk2/ShellPkg/Application/Shell/ShellProtocol.c 2015-12-25
01:52:56 UTC (rev 19529)
@@ -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