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>
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
Main file for DevTree shell Driver1 function.
|
Main file for DevTree shell Driver1 function.
|
||||||
|
|
||||||
(C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
|
(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
|
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
|
||||||
@ -58,6 +58,7 @@ DoDevTreeForHandle(
|
|||||||
ChildCount = 0;
|
ChildCount = 0;
|
||||||
|
|
||||||
ASSERT (TheHandle != NULL);
|
ASSERT (TheHandle != NULL);
|
||||||
|
ASSERT (HiiString != NULL);
|
||||||
|
|
||||||
if (ShellGetExecutionBreakFlag()) {
|
if (ShellGetExecutionBreakFlag()) {
|
||||||
ShellStatus = SHELL_ABORTED;
|
ShellStatus = SHELL_ABORTED;
|
||||||
@ -92,9 +93,9 @@ DoDevTreeForHandle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
|
FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));
|
||||||
|
if (FormatString == NULL) {
|
||||||
ASSERT(HiiString != NULL);
|
return SHELL_OUT_OF_RESOURCES;
|
||||||
ASSERT(FormatString != NULL);
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// we generate the format string on the fly so that we can control the
|
// we generate the format string on the fly so that we can control the
|
||||||
|
Reference in New Issue
Block a user