]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/EfiCompress.c
BaseTools: Update BrotliCompress script to handle the different input format
[mirror_edk2.git] / BaseTools / Source / C / Common / EfiCompress.c
index aafa9c6e24b6f4c16923869a1bcdafcad42e6cd6..b225fee913bec3369eb4f92cd5137b36a85a59fd 100644 (file)
@@ -1,7 +1,11 @@
 /** @file\r
-\r
-Copyright (c) 2006 - 2008, Intel Corporation                                              \r
-All rights reserved. This program and the accompanying materials                          \r
+Compression routine. The compression algorithm is a mixture of LZ77 and Huffman \r
+coding. LZ77 transforms the source data into a sequence of Original Characters \r
+and Pointers to repeated strings. This sequence is further divided into Blocks \r
+and Huffman codings are applied to each Block.\r
+  \r
+Copyright (c) 2006 - 2014, 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
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -9,18 +13,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-Module Name:\r
-\r
-  EfiCompress.c\r
-\r
-Abstract:\r
-\r
-  Compression routine. The compression algorithm is a mixture of\r
-  LZ77 and Huffman coding. LZ77 transforms the source data into a\r
-  sequence of Original Characters and Pointers to repeated strings.\r
-  This sequence is further divided into Blocks and Huffman codings\r
-  are applied to each Block.\r
-\r
 **/\r
 \r
 #include "Compress.h"\r
@@ -416,6 +408,9 @@ Returns:
   UINT32      i;\r
   \r
   mText       = malloc (WNDSIZ * 2 + MAXMATCH);\r
+  if (mText == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
   for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) {\r
     mText[i] = 0;\r
   }\r
@@ -426,6 +421,10 @@ Returns:
   mParent     = malloc (WNDSIZ * 2 * sizeof(*mParent));\r
   mPrev       = malloc (WNDSIZ * 2 * sizeof(*mPrev));\r
   mNext       = malloc ((MAX_HASH_VAL + 1) * sizeof(*mNext));\r
+  if (mLevel == NULL || mChildCount == NULL || mPosition == NULL ||\r
+    mParent == NULL || mPrev == NULL || mNext == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
   \r
   mBufSiz = 16 * 1024U;\r
   while ((mBuf = malloc(mBufSiz)) == NULL) {\r