diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-12 21:40:12 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-12 21:40:12 +0000 |
commit | ff51746bd46b25a88eb6c131c52e1d9fd610af28 (patch) | |
tree | 81daad0e45e04e9171714e22b59e356e0c426e2e /ShellPkg/Library/UefiShellCommandLib | |
parent | a12e31e6801ba07da25425bb546a65a61a78b1c2 (diff) | |
download | edk2-platforms-ff51746bd46b25a88eb6c131c52e1d9fd610af28.tar.xz |
update error handling to use less ASSERT.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11053 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellCommandLib')
-rw-r--r-- | ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index 4aec5d44ca..2dd39ef3cf 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -1171,7 +1171,8 @@ ConvertShellHandleToEfiFileProtocol( @param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.
@param[in] Path The path to the file for verification.
- @return a SHELL_FILE_HANDLE representing the same file.
+ @return A SHELL_FILE_HANDLE representing the same file.
+ @retval NULL There was not enough memory.
**/
SHELL_FILE_HANDLE
EFIAPI
@@ -1185,11 +1186,18 @@ ConvertEfiFileProtocolToShellHandle( if (Path != NULL) {
Buffer = AllocateZeroPool(sizeof(SHELL_COMMAND_FILE_HANDLE));
- ASSERT(Buffer != NULL);
+ if (Buffer == NULL) {
+ return (NULL);
+ }
NewNode = AllocatePool(sizeof(BUFFER_LIST));
- ASSERT(NewNode != NULL);
+ if (NewNode == NULL) {
+ return (NULL);
+ }
Buffer->FileHandle = (EFI_FILE_PROTOCOL*)Handle;
Buffer->Path = StrnCatGrow(&Buffer->Path, NULL, Path, 0);
+ if (Buffer->Path == NULL) {
+ return (NULL);
+ }
NewNode->Buffer = Buffer;
InsertHeadList(&mFileHandleList.Link, &NewNode->Link);
@@ -1244,8 +1252,10 @@ ShellFileHandleRemove( ; Node = (BUFFER_LIST*)GetNextNode(&mFileHandleList.Link, &Node->Link)
){
if ((Node->Buffer) && (((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->FileHandle == Handle)){
- SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
RemoveEntryList(&Node->Link);
+ SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE *)Node->Buffer)->Path);
+ SHELL_FREE_NON_NULL(Node->Buffer);
+ SHELL_FREE_NON_NULL(Node);
return (TRUE);
}
}
|