mirror of
https://github.com/status-im/nimPNG.git
synced 2025-02-07 02:05:02 +00:00
fixes #20, unreliable readStr
This commit is contained in:
parent
55a444cf5a
commit
efa7a47576
@ -896,7 +896,7 @@ proc parsePNG(s: Stream, settings: PNGDecoder): PNG =
|
|||||||
let length = s.readInt32BE()
|
let length = s.readInt32BE()
|
||||||
let chunkType = PNGChunkType(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 crc = cast[uint32](s.readInt32BE())
|
||||||
let calculatedCRC = crc32(crc32(0, $chunkType), data)
|
let calculatedCRC = crc32(crc32(0, $chunkType), data)
|
||||||
if calculatedCRC != crc and not PNGDecoder(png.settings).ignoreCRC:
|
if calculatedCRC != crc and not PNGDecoder(png.settings).ignoreCRC:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Package
|
# Package
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
author = "Andri Lim"
|
author = "Andri Lim"
|
||||||
description = "PNG encoder and decoder"
|
description = "PNG encoder and decoder"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user