about summary refs log tree commit diff stats
path: root/src/img
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-25 07:23:26 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-25 07:23:26 +0200
commit858c0315b3ce46ca697491c9874ef3f65fa9a46b (patch)
tree6e55e4920da87c58a800d733fcd323d31718924e /src/img
parent14b871eb7eaf329b67b71385597f114f8782318a (diff)
downloadchawan-858c0315b3ce46ca697491c9874ef3f65fa9a46b.tar.gz
png: fix off by one
+ remove outdated comment
Diffstat (limited to 'src/img')
-rw-r--r--src/img/png.nim4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/img/png.nim b/src/img/png.nim
index bd7e6206..d41360a3 100644
--- a/src/img/png.nim
+++ b/src/img/png.nim
@@ -266,11 +266,9 @@ func paethPredictor(a, b, c: uint16): uint16 =
   return if pa <= pb and pa <= pc: a elif pb <= pc: b else: c
 
 proc unfilter(reader: var PNGReader; irow: openArray[uint8]; bpp: int) =
-  # none, sub, up -> replace uprow directly
-  # average, paeth -> copy to temp array, then replace uprow
   case irow[0]
   of 0u8: # none
-    copyMem(addr reader.uprow[0], unsafeAddr irow[1], irow.len)
+    copyMem(addr reader.uprow[0], unsafeAddr irow[1], irow.len - 1)
   of 1u8: # sub
     for i in 1 ..< irow.len:
       let j = i - 1 # skip filter byte