diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-12 18:06:58 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-07-25 11:04:34 +0800 |
commit | 96269c3cb7a323d657a40048aff3c6966571a645 (patch) | |
tree | 0f1834d6d96caee63ab02ebaa487c1af213b2382 | |
parent | 23f12576d02eb199e5f8aca42d93bcacd3fef8c8 (diff) | |
download | edk2-platforms-96269c3cb7a323d657a40048aff3c6966571a645.tar.xz |
ShellPkg/LoadPciRom: 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 20cfed165c47a7ff578e469e4cf00f1a656eccbd)
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c index 1b94746933..1b284c2d87 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c @@ -2,7 +2,7 @@ Main file for LoadPciRom shell Debug1 function.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 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
@@ -147,7 +147,11 @@ ShellCommandRunLoadPciRom ( }
SourceSize = (UINTN) Node->Info->FileSize;
File1Buffer = AllocateZeroPool (SourceSize);
- ASSERT(File1Buffer != NULL);
+ if (File1Buffer == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"loadpcirom");
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ continue;
+ }
Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);
|