summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2014-01-09 18:05:24 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-09 18:05:24 +0000
commit4f67c7ffa1ed419e44084b2679c49a2f4e95ba65 (patch)
treeed9a7b22c1e3dabc523b120b55ba97701bfa0c09 /ShellPkg/Library
parent4922715d85564441d7cf16bac1a1fa67673f6877 (diff)
downloadedk2-platforms-4f67c7ffa1ed419e44084b2679c49a2f4e95ba65.tar.xz
ShellPkg: remove memory leak in file handle list
The shell was not freeing sufficient memory when freeing a list of files. The structure contained a pointer which was being left behind. I made a new function to replace the shared freeing function which frees the “Path” member of the SHELL_COMMAND_FILE_HANDLE structure. 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@15073 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 935e8397fe..48be39f832 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell internal functions for shell commands.
- 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
@@ -101,6 +101,37 @@ ShellCommandLibConstructor (
}
/**
+ Frees list of file handles.
+
+ @param[in] List The list to free.
+**/
+VOID
+EFIAPI
+FreeFileHandleList (
+ IN BUFFER_LIST *List
+ )
+{
+ BUFFER_LIST *BufferListEntry;
+
+ if (List == NULL){
+ return;
+ }
+ //
+ // enumerate through the buffer list and free all memory
+ //
+ for ( BufferListEntry = ( BUFFER_LIST *)GetFirstNode(&List->Link)
+ ; !IsListEmpty (&List->Link)
+ ; BufferListEntry = (BUFFER_LIST *)GetFirstNode(&List->Link)
+ ){
+ RemoveEntryList(&BufferListEntry->Link);
+ ASSERT(BufferListEntry->Buffer != NULL);
+ SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE*)(BufferListEntry->Buffer))->Path);
+ SHELL_FREE_NON_NULL(BufferListEntry->Buffer);
+ SHELL_FREE_NON_NULL(BufferListEntry);
+ }
+}
+
+/**
Destructor for the library. free any resources.
@param ImageHandle the image handle of the process
@@ -169,7 +200,7 @@ ShellCommandLibDestructor (
}
}
if (!IsListEmpty(&mFileHandleList.Link)){
- FreeBufferList(&mFileHandleList);
+ FreeFileHandleList(&mFileHandleList);
}
if (mProfileList != NULL) {