ShellPkg/For: 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:
@ -2,7 +2,7 @@
|
|||||||
Main file for endfor and for shell level 1 functions.
|
Main file for endfor and for shell level 1 functions.
|
||||||
|
|
||||||
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
||||||
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -414,7 +414,10 @@ ShellCommandRunFor (
|
|||||||
NewSize = StrSize(ArgSet);
|
NewSize = StrSize(ArgSet);
|
||||||
NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]);
|
NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]);
|
||||||
Info = AllocateZeroPool(NewSize);
|
Info = AllocateZeroPool(NewSize);
|
||||||
ASSERT(Info != NULL);
|
if (Info == NULL) {
|
||||||
|
FreePool (ArgSet);
|
||||||
|
return SHELL_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
||||||
CopyMem(Info->Set, ArgSet, StrSize(ArgSet));
|
CopyMem(Info->Set, ArgSet, StrSize(ArgSet));
|
||||||
NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]);
|
NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]);
|
||||||
@ -458,7 +461,10 @@ ShellCommandRunFor (
|
|||||||
// set up for a 'run' for loop
|
// set up for a 'run' for loop
|
||||||
//
|
//
|
||||||
Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));
|
Info = AllocateZeroPool(sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]));
|
||||||
ASSERT(Info != NULL);
|
if (Info == NULL) {
|
||||||
|
FreePool (ArgSet);
|
||||||
|
return SHELL_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
|
||||||
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
|
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
|
||||||
Info->ReplacementName = Info->Set;
|
Info->ReplacementName = Info->Set;
|
||||||
|
Reference in New Issue
Block a user