diff options
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; } |