opngreduc.c:957: opng_reduce_to_palette: Assertion `index >= 0' failed.
Advanced PNG optimization program
Status: Beta
Brought to you by:
cosmin
SHA1: 96fba39b76a07e1f254b8fc4b08e3fd6405e930c
./0.7.7/bin/optipng optipng-opng_reduce_to_palette-abort.png ** Processing: optipng-opng_reduce_to_palette-abort.png Warning: gAMA: CRC error Warning: tRNS: CRC error Warning: tRNS: invalid with alpha channel Warning: bad adaptive filter value 57x57 pixels, 4x8 bits/pixel, RGB+alpha optipng: opngreduc.c:957: opng_reduce_to_palette: Assertion `index >= 0' failed. Aborted
Thanks to Kapsi internet-käyttäjät ry for providing valuable fuzzing resources.
Hello, and thank you for the defect report.
The error occurs because of an undetected bad bKGD chunk, with 16-bit color samples in a 8-bit RGB image. The reduction code in opngreduc.c gets confused because it expects valid PNG data from libpng, but libpng fails to perform this particular check.
Here is the fix that applies to libpng v1.6.34 embedded in OptiPNG v0.7.7. The upstream libpng needs this fix (or a similar fix) also.
Luckily, assertions are never disabled, and, for this reason, the consequence of this defect is a merely inconvenient crash, not as dangerous as it could otherwise have been.
This issue can be Closed.
It was fixed upstream (commit).
The bundled version remains out of date.