]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/EfiCompress.c
ShellPkg: Update header file including style
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / EfiCompress.c
index d3c6af39990ea15bc00ea81007f8d69b5572264c..d94acf4e4b1acc5087610e9018b51b844870455f 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Main file for EfiCompress shell Debug1 function.\r
 \r
-  Copyright (c) 2015, Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<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
@@ -116,20 +116,26 @@ ShellCommandRunEfiCompress (
           Status = gEfiShellProtocol->GetFileSize(InShellFileHandle, &InSize);\r
           ASSERT_EFI_ERROR(Status);\r
           InBuffer = AllocateZeroPool((UINTN)InSize);\r
-          ASSERT(InBuffer != NULL);\r
-          InSize2 = (UINTN)InSize;\r
-          Status = gEfiShellProtocol->ReadFile(InShellFileHandle, &InSize2, InBuffer);\r
-          InSize = InSize2;\r
-          ASSERT_EFI_ERROR(Status);\r
-          Status = Compress(InBuffer, InSize, OutBuffer, &OutSize);\r
-          if (Status == EFI_BUFFER_TOO_SMALL) {\r
-            OutBuffer = AllocateZeroPool((UINTN)OutSize);\r
-            ASSERT(OutBuffer != NULL);\r
-            Status = Compress(InBuffer, InSize, OutBuffer, &OutSize);\r
+          if (InBuffer == NULL) {\r
+            Status = EFI_OUT_OF_RESOURCES;\r
+          } else {\r
+            InSize2 = (UINTN) InSize;\r
+            Status = gEfiShellProtocol->ReadFile (InShellFileHandle, &InSize2, InBuffer);\r
+            InSize = InSize2;\r
+            ASSERT_EFI_ERROR (Status);\r
+            Status = Compress (InBuffer, InSize, OutBuffer, &OutSize);\r
+            if (Status == EFI_BUFFER_TOO_SMALL) {\r
+              OutBuffer = AllocateZeroPool ((UINTN) OutSize);\r
+              if (OutBuffer == NULL) {\r
+                Status = EFI_OUT_OF_RESOURCES;\r
+              } else {\r
+                Status = Compress (InBuffer, InSize, OutBuffer, &OutSize);\r
+              }\r
+            }\r
           }\r
           if (EFI_ERROR(Status)) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_EFI_COMPRESS_FAIL), gShellDebug1HiiHandle, Status);\r
-            ShellStatus = SHELL_DEVICE_ERROR;\r
+            ShellStatus = ((Status == EFI_OUT_OF_RESOURCES) ? SHELL_OUT_OF_RESOURCES : SHELL_DEVICE_ERROR);\r
           } else {\r
             OutSize2 = (UINTN)OutSize;\r
             Status = gEfiShellProtocol->WriteFile(OutShellFileHandle, &OutSize2, OutBuffer);\r