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 make it consistent in this file. So:
> 
> diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
> index 244467b5..32422edc 100644
> --- a/libelf/elf_compress.c
> +++ b/libelf/elf_compress.c
> @@ -197,7 +197,7 @@ __libelf_compress (Elf_Scn *scn, size_t hsize, int 
> ei_data,
>      }
>    while (flush != Z_FINISH); /* More data blocks.  */
>  
> -  zrc = deflateEnd (&z);
> +  deflateEnd (&z);
>    if (zrc != Z_OK)
>      {
>        __libelf_seterrno (ELF_E_COMPRESS_ERROR);
> @@ -251,8 +251,7 @@ __libelf_decompress (void *buf_in, size_t size_in, size_t 
> size_out)
>         }
>        zrc = inflateReset (&z);
>      }
> -  if (likely (zrc == Z_OK))
> -    zrc = inflateEnd (&z);
> +  inflateEnd (&z);
>  
>    if (unlikely (zrc != Z_OK) || unlikely (z.avail_out != 0))
>      {

Obviously, I didn't look that closely, because when you apply the
above it causes multiple testcase failures. Oops. Sorry, back to the
drawing board. I suspect the zrz = deflateEnd in the compress case is
different from inflateEnd in the decompress case...

Cheers,

Mark

Reply via email to