about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-07-27 19:33:22 +0200
committerbptato <nincsnevem662@gmail.com>2024-07-27 19:34:18 +0200
commit497337cb07474b11fd64ca03009024a59774ce11 (patch)
tree00406b69de8180755d194d47562a630df47cccfa /src/loader
parent5b497ea25ad133c86b4cc09c2dbbf02150bcc8bf (diff)
downloadchawan-497337cb07474b11fd64ca03009024a59774ce11.tar.gz
loader: fix saveToBitmap for 0-len images
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/response.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/loader/response.nim b/src/loader/response.nim
index 5531da9d..9c173188 100644
--- a/src/loader/response.nim
+++ b/src/loader/response.nim
@@ -225,7 +225,11 @@ proc saveToBitmap*(response: Response; bmp: Bitmap): EmptyPromise =
   let size = bmp.width * bmp.height
   bmp.px = cast[seq[RGBAColorBE]](newSeqUninitialized[uint32](size))
   response.opaque = opaque
-  response.onRead = onReadBitmap
+  if size > 0:
+    response.onRead = onReadBitmap
+  else:
+    response.unregisterFun()
+    response.body.sclose()
   response.bodyUsed = true
   response.resume()
   return response.bodyRead