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]
On error,
zlib_codec_init
frees the first argument, but that's in various cases not something meant to be freed: