libelf: Fix double free in __libelf_compress on error path.

In commit 2092865a7e
"libelf: {de,}compress: ensure zlib resource cleanup" we added a
call to deflate_cleanup to make sure all resources were freed.
As GCC10 -fanalyzer points out that could cause a double free
of out_buf. Fix by removing the free (out_buf) in __libelf_compress.

Signed-off-by: Mark Wielaard <mark@klomp.org>
This commit is contained in:
Mark Wielaard
2020-04-25 01:21:12 +02:00
parent 554352ded7
commit a5d73b3e51
2 changed files with 4 additions and 1 deletions
+4
View File
@@ -1,3 +1,7 @@
2020-04-25 Mark Wielaard <mark@klomp.org>
* elf_compress.c (__libelf_compress): Remove free (out_buf).
2020-03-18 Omar Sandoval <osandov@fb.com>
* elf_getphdrnum.c (__elf_getphdrnum_rdlock): Call
-1
View File
@@ -113,7 +113,6 @@ __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 deflate_cleanup(NULL, NULL);
}