summaryrefslogtreecommitdiff
path: root/ShellPkg/Application
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2014-01-09 17:59:46 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-09 17:59:46 +0000
commitc1f9c34621fae9bec20c2b2fce134b9dba2b0ba1 (patch)
tree785864176a093d99a75c3bc186a1bb947529cd6a /ShellPkg/Application
parent705bffb568b36813ff6eccbe5a93cffb0b143044 (diff)
downloadedk2-platforms-c1f9c34621fae9bec20c2b2fce134b9dba2b0ba1.tar.xz
ShellPkg: Remove memory leak from file list usage
This change removes an un-used parameter that was then causing a leak since the memory was assumed to be used. This also verifies that the list is freed when no longer needed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-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@15071 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application')
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c18
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.h4
2 files changed, 8 insertions, 14 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index a337e5829e..b67aefb71c 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -2,7 +2,7 @@
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PROTOCOL.
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1619,6 +1619,7 @@ EfiShellFreeFileList(
RemoveEntryList(&ShellFileListItem->Link);
InternalFreeShellFileInfoNode(ShellFileListItem);
}
+ InternalFreeShellFileInfoNode(*FileList);
return(EFI_SUCCESS);
}
@@ -1714,7 +1715,6 @@ InternalDuplicateShellFileInfo(
@param[in] BasePath the Path to prepend onto filename for FullPath
@param[in] Status Status member initial value.
- @param[in] FullName FullName member initial value.
@param[in] FileName FileName member initial value.
@param[in] Handle Handle member initial value.
@param[in] Info Info struct to copy.
@@ -1727,7 +1727,6 @@ EFIAPI
CreateAndPopulateShellFileInfo(
IN CONST CHAR16 *BasePath,
IN CONST EFI_STATUS Status,
- IN CONST CHAR16 *FullName,
IN CONST CHAR16 *FileName,
IN CONST SHELL_FILE_HANDLE Handle,
IN CONST EFI_FILE_INFO *Info
@@ -1836,6 +1835,7 @@ EfiShellFindFilesInDir(
Size = 0;
TempString = StrnCatGrow(&TempString, &Size, ShellFileHandleGetPath(FileDirHandle), 0);
if (TempString == NULL) {
+ SHELL_FREE_NON_NULL(BasePath);
return (EFI_OUT_OF_RESOURCES);
}
TempSpot = StrStr(TempString, L";");
@@ -1846,8 +1846,10 @@ EfiShellFindFilesInDir(
TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);
if (TempString == NULL) {
+ SHELL_FREE_NON_NULL(BasePath);
return (EFI_OUT_OF_RESOURCES);
}
+ SHELL_FREE_NON_NULL(BasePath);
BasePath = TempString;
}
@@ -1862,20 +1864,14 @@ EfiShellFindFilesInDir(
; !EFI_ERROR(Status) && !NoFile
; Status = FileHandleFindNextFile(FileDirHandle, FileInfo, &NoFile)
){
- TempString = NULL;
- Size = 0;
//
// allocate a new EFI_SHELL_FILE_INFO and populate it...
//
- ASSERT((TempString == NULL && Size == 0) || (TempString != NULL));
- TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);
- TempString = StrnCatGrow(&TempString, &Size, FileInfo->FileName, 0);
ShellFileListItem = CreateAndPopulateShellFileInfo(
BasePath,
- EFI_SUCCESS, // success since we didnt fail to open it...
- TempString,
+ EFI_SUCCESS, // success since we didnt fail to open it...
FileInfo->FileName,
- NULL, // no handle since not open
+ NULL, // no handle since not open
FileInfo);
if (ShellFileList == NULL) {
diff --git a/ShellPkg/Application/Shell/ShellProtocol.h b/ShellPkg/Application/Shell/ShellProtocol.h
index 456aa2aff3..7493c9f49f 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.h
+++ b/ShellPkg/Application/Shell/ShellProtocol.h
@@ -2,7 +2,7 @@
Member functions of EFI_SHELL_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PROTOCOL.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -555,7 +555,6 @@ EfiShellRemoveDupInFileList(
@param[in] BasePath the Path to prepend onto filename for FullPath
@param[in] Status Status member initial value.
- @param[in] FullName FullName member initial value.
@param[in] FileName FileName member initial value.
@param[in] Handle Handle member initial value.
@param[in] Info Info struct to copy.
@@ -566,7 +565,6 @@ EFIAPI
CreateAndPopulateShellFileInfo(
IN CONST CHAR16 *BasePath,
IN CONST EFI_STATUS Status,
- IN CONST CHAR16 *FullName,
IN CONST CHAR16 *FileName,
IN CONST SHELL_FILE_HANDLE Handle,
IN CONST EFI_FILE_INFO *Info