X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FHexEdit%2FFileImage.c;h=2517a57f593dd05afb5f5858297cbf4f175e5bef;hb=7162fdb037fb9385f6bd7d0dc55d54029b810de2;hp=f5fb7d262a8a60a493908c0709ceb6dad8bc412b;hpb=ecae51177e83db0d99f8b4888ae4b866c18651b6;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c index f5fb7d262a..2517a57f59 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c @@ -1,7 +1,7 @@ /** @file Functions to deal with file buffer. - Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
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 @@ -169,8 +169,11 @@ HFileImageRead ( // you should set the status string // Status = ReadFileIntoBuffer (FileName, (VOID**)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly); - if (EFI_ERROR(Status) || Buffer == NULL) { - UnicodeBuffer = CatSPrint(NULL, L"Read error on file &s: %r", FileName, Status); + // + // NULL pointer is only also a failure for a non-zero file size. + // + if ((EFI_ERROR(Status)) || (Buffer == NULL && HFileImage.Size != 0)) { + UnicodeBuffer = CatSPrint(NULL, L"Read error on file %s: %r", FileName, Status); if (UnicodeBuffer == NULL) { SHELL_FREE_NON_NULL(Buffer); return EFI_OUT_OF_RESOURCES; @@ -178,6 +181,7 @@ HFileImageRead ( StatusBarSetStatusString (UnicodeBuffer); FreePool (UnicodeBuffer); + return EFI_OUT_OF_RESOURCES; } HFileImageSetFileName (FileName);