rtissera / libchdr

Standalone library for reading MAME's CHDv1-v5 formats.
BSD 3-Clause "New" or "Revised" License
98 stars 42 forks source link

Invalid use of free in zlib_codec_init #67

Closed Vogtinator closed 2 years ago

Vogtinator commented 2 years ago

On error, zlib_codec_init frees the first argument, but that's in various cases not something meant to be freed:

In function 'zlib_codec_init',
    inlined from 'cdfl_codec_init' at libchdr_chd.c:794:8:
libchdr_chd.c:2604:17: warning: 'free' called on pointer 'codec' with nonzero offset 184 [-Wfree-nonheap-object]
 2604 |                 free(data);
      |                 ^~~~~~~~~~
libchdr_chd.c:2604:17: warning: 'free' called on pointer 'codec' with nonzero offset 184 [-Wfree-nonheap-object]
In function 'zlib_codec_init',
    inlined from 'cdzl_codec_init' at libchdr_chd.c:689:8,
    inlined from 'cdzl_codec_init' at libchdr_chd.c:671:18:
libchdr_chd.c:2604:17: warning: 'free' called on pointer 'codec' with nonzero offset 1136 [-Wfree-nonheap-object]
 2604 |                 free(data);
      |                 ^~~~~~~~~~
In function 'zlib_codec_init',
    inlined from 'cdlz_codec_init' at libchdr_chd.c:603:8:
libchdr_chd.c:2604:17: warning: 'free' called on pointer 'codec' with nonzero offset 1176 [-Wfree-nonheap-object]
 2604 |                 free(data);
      |                 ^~~~~~~~~~
libchdr_chd.c:2604:17: warning: 'free' called on pointer 'codec' with nonzero offset 1176 [-Wfree-nonheap-object]
Zero3K commented 2 years ago

When will it be fixed?