allow extra compressed data

This commit is contained in:
Adam D. Ruppe 2022-07-27 13:45:08 -04:00
parent 9401143d98
commit 6d5eeec2cb
1 changed files with 7 additions and 0 deletions

7
png.d
View File

@ -1377,6 +1377,13 @@ struct LazyPngFile(LazyPngChunksProvider)
auto err = inflate(zs, Z_SYNC_FLUSH);
if (err != Z_STREAM_END && err != Z_OK) throw new Exception("PNG unpack error");
if (err == Z_STREAM_END) {
// this thing is malformed
if(zs.avail_in != 0) {
// libpng would warn here "libpng warning: IDAT: Extra compressed data"
// i used to just throw with the assertion on the next line
// but now just gonna discard the extra data to be a bit more permissive
zs.avail_in = 0;
}
assert(zs.avail_in == 0);
eoz = true;
}