LibGfx: Reject ICOs with height == NumericLimits<i32>::min()

Bitmap files use negative height values to signify that the image
should be rendered top down, but if the height value equals to the
minimum value, negating it to get the actual height results in UB.
This commit is contained in:
Idan Horowitz 2021-05-29 17:47:12 +03:00 committed by Ali Mohammad Pur
parent 4a2cb70e83
commit 7572a355fd
Notes: sideshowbarker 2024-07-18 17:12:44 +09:00

View File

@ -210,6 +210,13 @@ static bool load_ico_bmp(ICOLoadingContext& context, ICOImageDescriptor& desc)
printf("load_ico_bmp: width %d < 0\n", info.width);
return false;
}
if (info.height == NumericLimits<i32>::min()) {
if constexpr (ICO_DEBUG)
printf("load_ico_bmp: height == NumericLimits<i32>::min()\n");
return false;
}
bool topdown = false;
if (info.height < 0) {
topdown = true;