data len check

This commit is contained in:
Ryan Oldenburg 2020-11-20 13:51:43 -06:00
parent 42da6582cf
commit c114ca02dd

View file

@ -23,6 +23,10 @@ proc decodeBmp*(data: string): Image =
if compression notin [0, 3]:
raise newException(PixieError, "Invalid BMP data format")
let channels = if bits == 32: 4 else: 3
if width * height * channels + offset > data.len:
raise newException(PixieError, "Invalid BMP data size")
result = newImage(width, height)
for y in 0 ..< result.height: