diff options
author | Mark Wielaard <[email protected]> | 2020-06-11 23:16:21 +0200 |
---|---|---|
committer | Mark Wielaard <[email protected]> | 2020-06-11 23:16:21 +0200 |
commit | 50a6eeef7d87623faa65126dc3d16c2a8e613aea (patch) | |
tree | 19a35135efaac56c49a30316c6572c7b4d6ec4aa /libelf/elf_compress.c | |
parent | 49f13584d60322578c19b6118393ab04236ca7bf (diff) | |
parent | a2bc0214a5615551d89cef8d160bdbaafd5f1a83 (diff) |
Merge tag 'elfutils-0.180' into mjw/RH-DTSdts-0.180
elfutils 0.180 release
Diffstat (limited to 'libelf/elf_compress.c')
-rw-r--r-- | libelf/elf_compress.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c index 244467b5..e5d3d2e0 100644 --- a/libelf/elf_compress.c +++ b/libelf/elf_compress.c @@ -113,9 +113,8 @@ __libelf_compress (Elf_Scn *scn, size_t hsize, int ei_data, int zrc = deflateInit (&z, Z_BEST_COMPRESSION); if (zrc != Z_OK) { - free (out_buf); __libelf_seterrno (ELF_E_COMPRESS_ERROR); - return NULL; + return deflate_cleanup(NULL, NULL); } Elf_Data cdata; @@ -197,13 +196,13 @@ __libelf_compress (Elf_Scn *scn, size_t hsize, int ei_data, } while (flush != Z_FINISH); /* More data blocks. */ - zrc = deflateEnd (&z); - if (zrc != Z_OK) + if (zrc != Z_STREAM_END) { __libelf_seterrno (ELF_E_COMPRESS_ERROR); return deflate_cleanup (NULL, NULL); } + deflateEnd (&z); *new_size = used; return out_buf; } @@ -251,16 +250,15 @@ __libelf_decompress (void *buf_in, size_t size_in, size_t size_out) } zrc = inflateReset (&z); } - if (likely (zrc == Z_OK)) - zrc = inflateEnd (&z); if (unlikely (zrc != Z_OK) || unlikely (z.avail_out != 0)) { free (buf_out); + buf_out = NULL; __libelf_seterrno (ELF_E_DECOMPRESS_ERROR); - return NULL; } + inflateEnd(&z); return buf_out; } |