From e12bb51b474eb73a10f9a806198e70e7017f0a3e Mon Sep 17 00:00:00 2001 From: David Korth Date: Mon, 9 Jun 2025 21:05:24 -0400 Subject: [PATCH] [librptexture] ICOPrivate::loadImage_Win3(): Move the bitmap size check up a bit. --- src/librptexture/fileformat/ICO.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librptexture/fileformat/ICO.cpp b/src/librptexture/fileformat/ICO.cpp index ebbe75740..9f1f855d3 100644 --- a/src/librptexture/fileformat/ICO.cpp +++ b/src/librptexture/fileformat/ICO.cpp @@ -597,14 +597,15 @@ rp_image_const_ptr ICOPrivate::loadImage_Win3(void) // NOTE: Negative height is allowed for "right-side up". const unsigned int width = le32_to_cpu((unsigned int)(bih->biWidth)); const int orig_height = static_cast(le32_to_cpu(bih->biHeight)); - const bool is_upside_down = (orig_height > 0); const unsigned int height = abs(orig_height); - const unsigned int half_height = height / 2; if (width <= 0 || height == 0 || (height & 1)) { // Invalid bitmap size. return {}; } + const bool is_upside_down = (orig_height > 0); + const unsigned int half_height = height / 2; + // Only supporting 16-color images for now. // TODO: Handle BI_BITFIELDS? if (le32_to_cpu(bih->biPlanes) > 1) {