about summary refs log tree commit diff stats
path: root/src/img
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-04 23:26:35 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-04 23:26:35 +0200
commitaeba0d4737cbdd1f4cde4300cdc338eb8e10ff3d (patch)
tree3ab701bd13a8bb8a756fbe2003a153120ab1c299 /src/img
parenta0ea4c5ac02c750e692a4bbbc3e2d4a6952641e3 (diff)
downloadchawan-aeba0d4737cbdd1f4cde4300cdc338eb8e10ff3d.tar.gz
png: print zstream errors
Diffstat (limited to 'src/img')
-rw-r--r--src/img/png.nim6
1 files changed, 5 insertions, 1 deletions
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.