Tidy inflateEnd calls
authorAlan Modra <amodra@gmail.com>
Fri, 15 Jan 2021 23:15:09 +0000 (09:45 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 16 Jan 2021 00:41:52 +0000 (11:11 +1030)
So that no one need worry about the value of Z_OK.

bfd/
* compress.c (decompress_contents): Tidy inflateEnd result test.
binutils/
* readelf.c (uncompress_section_contents): Tidy inflateEnd result test.

bfd/ChangeLog
bfd/compress.c
binutils/ChangeLog
binutils/readelf.c

index d3282a3defbbd356f41d5db0a228ae2ef838c523..40534b8f7f1ebf015db06fc29a7b2ad7e5290901 100644 (file)
@@ -1,3 +1,7 @@
+2021-01-16  Alan Modra  <amodra@gmail.com>
+
+       * compress.c (decompress_contents): Tidy inflateEnd result test.
+
 2021-01-16  Alan Modra  <amodra@gmail.com>
 
        PR 26002
index 4cd9b2e6735771e104760909af0becc6fb39b865..2e73c760e757f108821620d4cc39e2eb9680afce 100644 (file)
@@ -60,8 +60,7 @@ decompress_contents (bfd_byte *compressed_buffer,
        break;
       rc = inflateReset (&strm);
     }
-  rc |= inflateEnd (&strm);
-  return rc == Z_OK && strm.avail_out == 0;
+  return inflateEnd (&strm) == Z_OK && rc == Z_OK && strm.avail_out == 0;
 }
 
 /* Compress data of the size specified in @var{uncompressed_size}
index 0e3ae10c8ac9480e0b234c0028f0598ac005a65b..efb86d2d5f6f33157eafc663d9cdb7bfd9d3e4fe 100644 (file)
@@ -1,3 +1,7 @@
+2021-01-16  Alan Modra  <amodra@gmail.com>
+
+       * readelf.c (uncompress_section_contents): Tidy inflateEnd result test.
+
 2021-01-15  Alan Modra  <amodra@gmail.com>
 
        PR 26539
index d828d5636df0b6172ab07ac6828e808fc521d225..5df51086226204a2660f062b8df94fac68782857 100644 (file)
@@ -14229,8 +14229,8 @@ uncompress_section_contents (unsigned char **   buffer,
         break;
       rc = inflateReset (& strm);
     }
-  rc |= inflateEnd (& strm);
-  if (rc != Z_OK
+  if (inflateEnd (& strm) != Z_OK
+      || rc != Z_OK
       || strm.avail_out != 0)
     goto fail;