add exception error if predefinedFilters not enough

This commit is contained in:
andri lim 2020-04-13 21:00:17 +07:00
parent f5580d7d77
commit c490027c55
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9

View File

@ -3150,6 +3150,10 @@ proc encoderCore(png: PNG) =
(modeOut.paletteSize == 0 or modeOut.paletteSize > 256): (modeOut.paletteSize == 0 or modeOut.paletteSize > 256):
raise PNGError("invalid palette size, it is only allowed to be 1-256") raise PNGError("invalid palette size, it is only allowed to be 1-256")
if state.filterStrategy == LFS_PREDEFINED:
if state.predefinedFilters.len < png.width:
raise PNGError("predefinedFilters contains not enough filterType compared to image height")
let inputSize = getRawSize(png.width, png.height, modeIn) let inputSize = getRawSize(png.width, png.height, modeIn)
if png.pixels.len < inputSize: if png.pixels.len < inputSize:
raise PNGError("not enough input to encode") raise PNGError("not enough input to encode")