Re: [PATCH] libelf: decompress: ensure zlib resource cleanup

2020-03-16 Thread Mark Wielaard
Hi, On Mon, Mar 16, 2020 at 01:05:26PM +0100, Mark Wielaard wrote: > Thanks for looking into this so closely. I think it is best to just do > as the example code does. Always call inflateEnd (), ignoring the > return code and not care whether (in an error case) it might be called > twice. And to m

Re: [PATCH] libelf: decompress: ensure zlib resource cleanup

2020-03-16 Thread Mark Wielaard
Hi Matthias, On Mon, Mar 16, 2020 at 12:42:22AM +0100, Matthias Maennich wrote: > > Just before this hunk we do: > > > > if (likely (zrc == Z_OK)) > >zrc = inflateEnd (&z); > > > > So, zrc can be !Z_OK because the earlier inflateEnd() failed, which > > might cause it to call inflateEnd() tw

Re: [PATCH] libelf: decompress: ensure zlib resource cleanup

2020-03-15 Thread Matthias Maennich via Elfutils-devel
Hi Mark! Thanks for the quick response! On Mon, Mar 16, 2020 at 12:10:51AM +0100, Mark Wielaard wrote: Hi Matthias, On Sun, 2020-03-15 at 23:03 +0100, Matthias Maennich via Elfutils-devel wrote: __libelf_decompress would only cleanup zlib resources via inflateEnd() in case inflating was succe

Re: [PATCH] libelf: decompress: ensure zlib resource cleanup

2020-03-15 Thread Mark Wielaard
Hi Matthias, On Sun, 2020-03-15 at 23:03 +0100, Matthias Maennich via Elfutils-devel wrote: > __libelf_decompress would only cleanup zlib resources via inflateEnd() > in case inflating was successful, but would leak memory if not. Fix this > by calling inflateEnd() in the error case as well. > >

[PATCH] libelf: decompress: ensure zlib resource cleanup

2020-03-15 Thread Matthias Maennich via Elfutils-devel
__libelf_decompress would only cleanup zlib resources via inflateEnd() in case inflating was successful, but would leak memory if not. Fix this by calling inflateEnd() in the error case as well. Fixes: 272018bba1f2 ("libelf: Add elf_compress and elf_compress_gnu.") Signed-off-by: Matthias Maennich