]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/LoadPciRom: Handle memory allocation failure
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 12 Jul 2016 10:06:58 +0000 (18:06 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Mon, 18 Jul 2016 02:55:32 +0000 (10:55 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c

index 1b94746933819b5a0f2b3c170af039fe1a1d9d72..1b284c2d8720d9dc6f4105c12483f96299543fed 100644 (file)
@@ -2,7 +2,7 @@
   Main file for LoadPciRom shell Debug1 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -147,7 +147,11 @@ ShellCommandRunLoadPciRom (
           }\r
           SourceSize  = (UINTN) Node->Info->FileSize;\r
           File1Buffer = AllocateZeroPool (SourceSize);\r
-          ASSERT(File1Buffer != NULL);\r
+          if (File1Buffer == NULL) {\r
+            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"loadpcirom");\r
+            ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+            continue;\r
+          }\r
           Status = gEfiShellProtocol->ReadFile(Node->Handle, &SourceSize, File1Buffer);\r
           if (EFI_ERROR(Status)) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_READ_FAIL), gShellDebug1HiiHandle, L"loadpcirom", Node->FullName);  \r