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) {