fixes #20, unreliable readStr

This commit is contained in:
andri lim 2018-05-17 11:04:40 +07:00
parent 55a444cf5a
commit efa7a47576
2 changed files with 2 additions and 2 deletions

View File

@ -896,7 +896,7 @@ proc parsePNG(s: Stream, settings: PNGDecoder): PNG =
let length = s.readInt32BE()
let chunkType = PNGChunkType(s.readInt32BE())
let data = s.readStr(length)
let data = if length == 0: "" else: s.readStr(length)
let crc = cast[uint32](s.readInt32BE())
let calculatedCRC = crc32(crc32(0, $chunkType), data)
if calculatedCRC != crc and not PNGDecoder(png.settings).ignoreCRC:

View File

@ -1,5 +1,5 @@
# Package
version = "0.2.1"
version = "0.2.2"
author = "Andri Lim"
description = "PNG encoder and decoder"
license = "MIT"