From 4fd92297e0a144881f37ffdb1c19fab6b0d3e47d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 22 Aug 2016 10:45:59 +0100 Subject: deal with unrepresentable negative heights in bitmap info header --- src/libnsbmp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libnsbmp.c') diff --git a/src/libnsbmp.c b/src/libnsbmp.c index b9bd8f5..c03d34b 100644 --- a/src/libnsbmp.c +++ b/src/libnsbmp.c @@ -180,7 +180,11 @@ static bmp_result bmp_info_header_parse(bmp_image *bmp, uint8_t *data) return BMP_DATA_ERROR; if (height < 0) { bmp->reversed = true; - height = -height; + if (height <= -INT32_MAX) { + height = INT32_MAX; + } else { + height = -height; + } } /* ICOs only support 256*256 resolutions * In the case of the ICO header, the height is actually the added -- cgit v1.2.3