diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-13 15:45:08 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-25 11:04:51 +0800 |
commit | 0280e405f746a74b0e824d624710f82702201d3c (patch) | |
tree | b951acc3cdd82fecb1d378fda8d29a0c55023ebb | |
parent | 3663fbc0b7fbb4fc77760fa78b6104050989d995 (diff) | |
download | edk2-platforms-0280e405f746a74b0e824d624710f82702201d3c.tar.xz |
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>
(cherry picked from commit 59b7dbac4ea075313af989cc20b71d44fdc7829a)
-rw-r--r-- | ShellPkg/Library/UefiShellLevel1CommandsLib/For.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c index cbf0517013..6cfe8a78fe 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -2,7 +2,7 @@ Main file for endfor and for shell level 1 functions.
(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
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
@@ -414,7 +414,10 @@ ShellCommandRunFor ( NewSize = StrSize(ArgSet);
NewSize += sizeof(SHELL_FOR_INFO)+StrSize(gEfiShellParametersProtocol->Argv[1]);
Info = AllocateZeroPool(NewSize);
- ASSERT(Info != NULL);
+ if (Info == NULL) {
+ FreePool (ArgSet);
+ return SHELL_OUT_OF_RESOURCES;
+ }
Info->Signature = SHELL_FOR_INFO_SIGNATURE;
CopyMem(Info->Set, ArgSet, StrSize(ArgSet));
NewSize = StrSize(gEfiShellParametersProtocol->Argv[1]);
@@ -458,7 +461,10 @@ ShellCommandRunFor ( // set up for a 'run' for loop
//
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;
CopyMem(Info->Set, gEfiShellParametersProtocol->Argv[1], StrSize(gEfiShellParametersProtocol->Argv[1]));
Info->ReplacementName = Info->Set;
|