diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-13 15:43:55 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-25 11:04:41 +0800 |
commit | 90604964ce730e9656d83c2da013381c25042d4c (patch) | |
tree | 3b4e197efb23e1e196be8136ba0360fc5993d414 | |
parent | 1729d7be7fb38952764e2ebc29bb764adfdb0164 (diff) | |
download | edk2-90604964ce730e9656d83c2da013381c25042d4c.tar.gz edk2-90604964ce730e9656d83c2da013381c25042d4c.tar.bz2 edk2-90604964ce730e9656d83c2da013381c25042d4c.zip |
ShellPkg/DevTree: 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 55b1d63de7677f89178f200404d8d05a23150a4a)
-rw-r--r-- | ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c index fb9de10a54..237cb85f94 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c @@ -2,7 +2,7 @@ Main file for DevTree shell Driver1 function.
(C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 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
@@ -57,7 +57,8 @@ DoDevTreeForHandle( ChildHandleBuffer = NULL;
ChildCount = 0;
- ASSERT(TheHandle != NULL);
+ ASSERT (TheHandle != NULL);
+ ASSERT (HiiString != NULL);
if (ShellGetExecutionBreakFlag()) {
ShellStatus = SHELL_ABORTED;
@@ -91,10 +92,10 @@ DoDevTreeForHandle( return SHELL_SUCCESS;
}
- FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
-
- ASSERT(HiiString != NULL);
- ASSERT(FormatString != NULL);
+ FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
+ if (FormatString == NULL) {
+ return SHELL_OUT_OF_RESOURCES;
+ }
//
// we generate the format string on the fly so that we can control the
|