summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellCommandLib
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2014-08-05 23:16:39 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2014-08-05 23:16:39 +0000
commitae315cc26984d308dbe07b8e01dea7c56a78f79d (patch)
tree8fba2adf60cd80be45744beb482be0786f807db2 /ShellPkg/Library/UefiShellCommandLib
parentc12383d5ea53e0a82577a45afaccb16761528541 (diff)
downloadedk2-ae315cc26984d308dbe07b8e01dea7c56a78f79d.tar.gz
edk2-ae315cc26984d308dbe07b8e01dea7c56a78f79d.tar.bz2
edk2-ae315cc26984d308dbe07b8e01dea7c56a78f79d.zip
Fix the use of ASSERT and other fixes to memory allocation failures (like free before return for errors)
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15759 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellCommandLib')
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index ef5acd7da8..ebb84dd55e 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -1392,7 +1392,9 @@ ShellCommandUpdateMapping (
// Get all Device Paths
//
DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
- ASSERT(DevicePathList != NULL);
+ if (DevicePathList == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
DevicePathList[Count] = DevicePathFromHandle(HandleList[Count]);
@@ -1408,7 +1410,7 @@ ShellCommandUpdateMapping (
//
// Assign new Mappings to remainders
//
- for (Count = 0 ; HandleList[Count] != NULL && !EFI_ERROR(Status); Count++) {
+ for (Count = 0 ; !EFI_ERROR(Status) && HandleList[Count] != NULL && !EFI_ERROR(Status); Count++) {
//
// Skip ones that already have
//
@@ -1419,7 +1421,10 @@ ShellCommandUpdateMapping (
// Get default name
//
NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem);
- ASSERT(NewDefaultName != NULL);
+ if (NewDefaultName == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ break;
+ }
//
// Call shell protocol SetMap function now...
@@ -1496,11 +1501,14 @@ ConvertEfiFileProtocolToShellHandle(
}
NewNode = AllocateZeroPool(sizeof(BUFFER_LIST));
if (NewNode == NULL) {
+ SHELL_FREE_NON_NULL(Buffer);
return (NULL);
}
Buffer->FileHandle = (EFI_FILE_PROTOCOL*)Handle;
Buffer->Path = StrnCatGrow(&Buffer->Path, NULL, Path, 0);
if (Buffer->Path == NULL) {
+ SHELL_FREE_NON_NULL(NewNode);
+ SHELL_FREE_NON_NULL(Buffer);
return (NULL);
}
NewNode->Buffer = Buffer;
@@ -1638,7 +1646,6 @@ FreeBufferList (
; BufferListEntry = (BUFFER_LIST *)GetFirstNode(&List->Link)
){
RemoveEntryList(&BufferListEntry->Link);
- ASSERT(BufferListEntry->Buffer != NULL);
if (BufferListEntry->Buffer != NULL) {
FreePool(BufferListEntry->Buffer);
}