mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-22 21:24:35 +02:00
ShellPkg/Shell.c: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
parent
977528bad7
commit
b2c036a7f0
@ -1330,7 +1330,10 @@ AddBufferToFreeList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BufferListEntry = AllocateZeroPool (sizeof (BUFFER_LIST));
|
BufferListEntry = AllocateZeroPool (sizeof (BUFFER_LIST));
|
||||||
ASSERT(BufferListEntry != NULL);
|
if (BufferListEntry == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
BufferListEntry->Buffer = Buffer;
|
BufferListEntry->Buffer = Buffer;
|
||||||
InsertTailList (&ShellInfoObject.BufferToFreeList.Link, &BufferListEntry->Link);
|
InsertTailList (&ShellInfoObject.BufferToFreeList.Link, &BufferListEntry->Link);
|
||||||
return (Buffer);
|
return (Buffer);
|
||||||
@ -1391,9 +1394,15 @@ AddLineToCommandHistory(
|
|||||||
|
|
||||||
|
|
||||||
Node = AllocateZeroPool(sizeof(BUFFER_LIST));
|
Node = AllocateZeroPool(sizeof(BUFFER_LIST));
|
||||||
ASSERT(Node != NULL);
|
if (Node == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Node->Buffer = AllocateCopyPool (StrSize (Buffer), Buffer);
|
Node->Buffer = AllocateCopyPool (StrSize (Buffer), Buffer);
|
||||||
ASSERT(Node->Buffer != NULL);
|
if (Node->Buffer == NULL) {
|
||||||
|
FreePool (Node);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for ( Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)
|
for ( Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)
|
||||||
; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
|
; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
|
||||||
@ -1721,7 +1730,9 @@ RunSplitCommand(
|
|||||||
// make a SPLIT_LIST item and add to list
|
// make a SPLIT_LIST item and add to list
|
||||||
//
|
//
|
||||||
Split = AllocateZeroPool(sizeof(SPLIT_LIST));
|
Split = AllocateZeroPool(sizeof(SPLIT_LIST));
|
||||||
ASSERT(Split != NULL);
|
if (Split == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
Split->SplitStdIn = StdIn;
|
Split->SplitStdIn = StdIn;
|
||||||
Split->SplitStdOut = ConvertEfiFileProtocolToShellHandle(CreateFileInterfaceMem(Unicode), NULL);
|
Split->SplitStdOut = ConvertEfiFileProtocolToShellHandle(CreateFileInterfaceMem(Unicode), NULL);
|
||||||
ASSERT(Split->SplitStdOut != NULL);
|
ASSERT(Split->SplitStdOut != NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user