Revision: 15073
http://sourceforge.net/p/edk2/code/15073
Author: jcarsey
Date: 2014-01-09 18:05:24 +0000 (Thu, 09 Jan 2014)
Log Message:
-----------
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
?\226?\128?\156Path?\226?\128?\157 member of the SHELL_COMMAND_FILE_HANDLE
structure.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>
Modified Paths:
--------------
trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
Modified: trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
2014-01-09 18:02:26 UTC (rev 15072)
+++ trunk/edk2/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
2014-01-09 18:05:24 UTC (rev 15073)
@@ -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 @@
}
/**
+ 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 @@
}
}
if (!IsListEmpty(&mFileHandleList.Link)){
- FreeBufferList(&mFileHandleList);
+ FreeFileHandleList(&mFileHandleList);
}
if (mProfileList != NULL) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits