summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellLib
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2016-07-13 17:39:37 +0800
committerHao Wu <hao.a.wu@intel.com>2016-07-25 11:05:08 +0800
commit985c765bb37788ac95e155ddb12c6241f2c25ff5 (patch)
treef27b8c8237d5ead56b5dea5a455315e00ac543fd /ShellPkg/Library/UefiShellLib
parent463d803d7c8e491ba0425bf6b89280261ae74415 (diff)
downloadedk2-platforms-985c765bb37788ac95e155ddb12c6241f2c25ff5.tar.xz
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> (cherry picked from commit 2efafabf41f05b88c421d97838f193eeb3f9c8e2)
Diffstat (limited to 'ShellPkg/Library/UefiShellLib')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 5e5e6271bf..e4e7e3d829 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -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),