From aeba0d4737cbdd1f4cde4300cdc338eb8e10ff3d Mon Sep 17 00:00:00 2001 From: bptato Date: Tue, 4 Jul 2023 23:26:35 +0200 Subject: png: print zstream errors --- src/img/png.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/img') diff --git a/src/img/png.nim b/src/img/png.nim index 247c3395..416c4541 100644 --- a/src/img/png.nim +++ b/src/img/png.nim @@ -380,7 +380,11 @@ proc readIDAT(reader: var PNGReader) = reader.strm.avail_out = cuint(olen) reader.strm.next_out = addr reader.idatBuf[reader.idatAt] let res = inflate(addr reader.strm, Z_NO_FLUSH) - doAssert res != Z_STREAM_ERROR + if res == Z_STREAM_ERROR: + if reader.strm.msg != nil: + reader.err "zstream error: " & $reader.strm.msg + else: + reader.err "unknown zstream error" case res of Z_NEED_DICT, Z_DATA_ERROR, Z_MEM_ERROR, Z_BUF_ERROR: # Z_BUF_ERROR is fatal here, as outlen is at least as large as idat. -- cgit 1.4.1-2-gfad0