summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-04 16:26:29 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-04 16:26:29 +0000
commit0ab85bef03a4265f928ea5c9dbfa2328658738ac (patch)
tree924fee2520d68741cd4d455fe05bbb2665ba5d7a /ShellPkg
parent40d7a9cfaa529a8ed50a039719c09c42e05c496f (diff)
downloadedk2-platforms-0ab85bef03a4265f928ea5c9dbfa2328658738ac.tar.xz
move DeleteScriptFileStruct from a private to a public function. This allows for better memory cleanup when errors occur.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10906 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Include/Library/ShellCommandLib.h11
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c29
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h11
3 files changed, 28 insertions, 23 deletions
diff --git a/ShellPkg/Include/Library/ShellCommandLib.h b/ShellPkg/Include/Library/ShellCommandLib.h
index 53cc80b4b5..af16c85ef3 100644
--- a/ShellPkg/Include/Library/ShellCommandLib.h
+++ b/ShellPkg/Include/Library/ShellCommandLib.h
@@ -420,6 +420,17 @@ ShellCommandSetNewScript (
);
/**
+ Function to cleanup all memory from a SCRIPT_FILE structure.
+
+ @param[in] Script The pointer to the structure to cleanup.
+**/
+VOID
+EFIAPI
+DeleteScriptFileStruct (
+ IN SCRIPT_FILE *Script
+ );
+
+/**
Function to get the current Profile string.
This is used to retrieve what profiles were installed.
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 5a3739ff91..4aec5d44ca 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -767,13 +767,16 @@ DeleteScriptFileStruct (
)
{
UINT8 LoopVar;
- ASSERT(Script != NULL);
- ASSERT(Script->ScriptName != NULL);
+
+ if (Script == NULL) {
+ return;
+ }
+
for (LoopVar = 0 ; LoopVar < Script->Argc ; LoopVar++) {
- FreePool(Script->Argv[LoopVar]);
+ SHELL_FREE_NON_NULL(Script->Argv[LoopVar]);
}
if (Script->Argv != NULL) {
- FreePool(Script->Argv);
+ SHELL_FREE_NON_NULL(Script->Argv);
}
Script->CurrentCommand = NULL;
while (!IsListEmpty (&Script->CommandList)) {
@@ -781,16 +784,16 @@ DeleteScriptFileStruct (
if (Script->CurrentCommand != NULL) {
RemoveEntryList(&Script->CurrentCommand->Link);
if (Script->CurrentCommand->Cl != NULL) {
- FreePool(Script->CurrentCommand->Cl);
+ SHELL_FREE_NON_NULL(Script->CurrentCommand->Cl);
}
if (Script->CurrentCommand->Data != NULL) {
- FreePool(Script->CurrentCommand->Data);
+ SHELL_FREE_NON_NULL(Script->CurrentCommand->Data);
}
- FreePool(Script->CurrentCommand);
+ SHELL_FREE_NON_NULL(Script->CurrentCommand);
}
}
- FreePool(Script->ScriptName);
- FreePool(Script);
+ SHELL_FREE_NON_NULL(Script->ScriptName);
+ SHELL_FREE_NON_NULL(Script);
}
/**
@@ -833,7 +836,6 @@ ShellCommandSetNewScript (
SCRIPT_FILE_LIST *Node;
if (Script == NULL) {
if (IsListEmpty (&mScriptList.Link)) {
- ASSERT(FALSE);
return (NULL);
}
Node = (SCRIPT_FILE_LIST *)GetFirstNode(&mScriptList.Link);
@@ -842,6 +844,9 @@ ShellCommandSetNewScript (
FreePool(Node);
} else {
Node = AllocateZeroPool(sizeof(SCRIPT_FILE_LIST));
+ if (Node == NULL) {
+ return (NULL);
+ }
Node->Data = Script;
InsertHeadList(&mScriptList.Link, &Node->Link);
}
@@ -1025,7 +1030,7 @@ ShellCommandCreateInitialMappingsAndPaths(
//
// Find each handle with Simple File System
//
- HandleList = GetHandleListByPotocol(&gEfiSimpleFileSystemProtocolGuid);
+ HandleList = GetHandleListByProtocol(&gEfiSimpleFileSystemProtocolGuid);
if (HandleList != NULL) {
//
// Do a count of the handles
@@ -1085,7 +1090,7 @@ ShellCommandCreateInitialMappingsAndPaths(
//
// Find each handle with Block Io
//
- HandleList = GetHandleListByPotocol(&gEfiBlockIoProtocolGuid);
+ HandleList = GetHandleListByProtocol(&gEfiBlockIoProtocolGuid);
if (HandleList != NULL) {
for (Count = 0 ; HandleList[Count] != NULL ; Count++);
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
index 6327ae54c5..ef81dd3f89 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.h
@@ -58,17 +58,6 @@ typedef struct {
SCRIPT_FILE *Data;
} SCRIPT_FILE_LIST;
-/**
- Function to cleanup all memory from a SCRIPT_FILE structure.
-
- @param[in] Script The pointer to the structure to cleanup.
-**/
-VOID
-EFIAPI
-DeleteScriptFileStruct (
- IN SCRIPT_FILE *Script
- );
-
typedef struct {
EFI_FILE_PROTOCOL *FileHandle;
CHAR16 *Path;