mirror of https://github.com/acidanthera/audk.git
ShellPkg/UefiShellLib: 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
28d447f9bd
commit
2efafabf41
|
@ -2021,6 +2021,7 @@ InternalCommandLineParse (
|
|||
UINTN Count;
|
||||
CONST CHAR16 *TempPointer;
|
||||
UINTN CurrentValueSize;
|
||||
CHAR16 *NewValue;
|
||||
|
||||
CurrentItemPackage = NULL;
|
||||
GetItemValue = 0;
|
||||
|
@ -2119,8 +2120,15 @@ InternalCommandLineParse (
|
|||
// get the item VALUE for a previous flag
|
||||
//
|
||||
CurrentValueSize = ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16);
|
||||
CurrentItemPackage->Value = ReallocatePool(ValueSize, CurrentValueSize, CurrentItemPackage->Value);
|
||||
ASSERT(CurrentItemPackage->Value != NULL);
|
||||
NewValue = ReallocatePool(ValueSize, CurrentValueSize, CurrentItemPackage->Value);
|
||||
if (NewValue == NULL) {
|
||||
SHELL_FREE_NON_NULL (CurrentItemPackage->Value);
|
||||
SHELL_FREE_NON_NULL (CurrentItemPackage);
|
||||
ShellCommandLineFreeVarList (*CheckPackage);
|
||||
*CheckPackage = NULL;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CurrentItemPackage->Value = NewValue;
|
||||
if (ValueSize == 0) {
|
||||
StrCpyS( CurrentItemPackage->Value,
|
||||
CurrentValueSize/sizeof(CHAR16),
|
||||
|
|
Loading…
Reference in New Issue