Make bfd_byte an int8_t, flagword a uint32_t
[binutils-gdb.git] / bfd / compress.c
index 2cf8a6c28c9e76772a1841f383f3f87a55db2ebc..844328b27a965f71295adb6d510b402cfdb565fa 100644 (file)
@@ -263,9 +263,6 @@ SYNOPSIS
 
 DESCRIPTION
        Return the size of the compression header of SEC in ABFD.
-
-RETURNS
-       Return the size of the compression header in bytes.
 */
 
 int
@@ -1068,7 +1065,8 @@ bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
       || sec->size == 0
       || sec->rawsize != 0
       || sec->contents != NULL
-      || sec->compress_status != COMPRESS_SECTION_NONE)
+      || sec->compress_status != COMPRESS_SECTION_NONE
+      || _bfd_section_size_insane (abfd, sec))
     {
       bfd_set_error (bfd_error_invalid_operation);
       return false;
@@ -1083,7 +1081,10 @@ bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
 
   if (!bfd_get_section_contents (abfd, sec, uncompressed_buffer,
                                 0, uncompressed_size))
-    return false;
+    {
+      free (uncompressed_buffer);
+      return false;
+    }
 
   sec->contents = uncompressed_buffer;
   if (bfd_compress_section_contents (abfd, sec) == 0)