]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
ShellPkg: Add checking for memory allocation and pointer returns from functions.
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / HexEdit / FileImage.c
index 85626626386511a59eb2ea55e22a980aba5ad015..ff3819c6c61aac604acc3230c73697dd9868a8c7 100644 (file)
@@ -169,7 +169,7 @@ HFileImageRead (
   // you should set the status string\r
   //\r
   Status = ReadFileIntoBuffer (FileName, (VOID**)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly);\r
-  if (EFI_ERROR(Status)) {\r
+  if (EFI_ERROR(Status) || Buffer == NULL) {\r
     UnicodeBuffer = CatSPrint(NULL, L"Read error on file &s: %r", FileName, Status);\r
     if (UnicodeBuffer == NULL) {\r
       SHELL_FREE_NON_NULL(Buffer);\r
@@ -178,6 +178,7 @@ HFileImageRead (
 \r
     StatusBarSetStatusString (UnicodeBuffer);\r
     FreePool (UnicodeBuffer);\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   HFileImageSetFileName (FileName);\r