From 3f869579a47a0c48119e256a5309526f41092812 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Tue, 13 Nov 2012 16:08:52 +0000 Subject: [PATCH] ShellPkg: Correct 3 places where memory was not being properly released by the shell. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey Reviewed-by: Erik Bjorge Reviewed-by: Liu, Jiang A git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13938 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Application/Shell/ShellEnvVar.c | 2 +- ShellPkg/Application/Shell/ShellParametersProtocol.c | 2 ++ .../Library/UefiShellCommandLib/UefiShellCommandLib.c | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellEnvVar.c b/ShellPkg/Application/Shell/ShellEnvVar.c index a4bd6a6179..6634c6951a 100644 --- a/ShellPkg/Application/Shell/ShellEnvVar.c +++ b/ShellPkg/Application/Shell/ShellEnvVar.c @@ -105,7 +105,7 @@ FreeEnvironmentVariableList( } for ( Node = (ENV_VAR_LIST*)GetFirstNode(List) - ; IsListEmpty(List) + ; !IsListEmpty(List) ; Node = (ENV_VAR_LIST*)GetFirstNode(List) ){ ASSERT(Node != NULL); diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index e152a7a3a0..9ce7e92605 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -192,6 +192,7 @@ ParseCommandLineToArgs( // (*Argv) = AllocateZeroPool((Count)*sizeof(CHAR16*)); if (*Argv == NULL) { + SHELL_FREE_NON_NULL(TempParameter); return (EFI_OUT_OF_RESOURCES); } @@ -207,6 +208,7 @@ ParseCommandLineToArgs( (*Argc)++; } ASSERT(Count >= (*Argc)); + SHELL_FREE_NON_NULL(TempParameter); return (EFI_SUCCESS); } diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index 971294ffd4..fb44768c0b 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -129,7 +129,7 @@ ShellCommandLibDestructor ( ) { SHELL_COMMAND_INTERNAL_LIST_ENTRY *Node; - COMMAND_LIST *Node2; + ALIAS_LIST *Node2; SCRIPT_FILE_LIST *Node3; SHELL_MAP_LIST *MapNode; // @@ -144,13 +144,14 @@ ShellCommandLibDestructor ( } // - // enumerate through the init command list and free all memory + // enumerate through the alias list and free all memory // while (!IsListEmpty (&mAliasList.Link)) { - Node2 = (COMMAND_LIST *)GetFirstNode(&mAliasList.Link); + Node2 = (ALIAS_LIST *)GetFirstNode(&mAliasList.Link); RemoveEntryList(&Node2->Link); SHELL_FREE_NON_NULL(Node2->CommandString); - FreePool(Node2); + SHELL_FREE_NON_NULL(Node2->Alias); + SHELL_FREE_NON_NULL(Node2); DEBUG_CODE(Node2 = NULL;); } -- 2.39.2