mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:07:43 +00:00
LibGfx: Avoid signed comparison in find_largest_image
I believe the issue was caused by the product of two u16s being promoted to (signed) int, which can cause unwanted overflow behaviour when comparing to size_t. Casting each term to size_t before the multiplication makes the comparison unsigned.
This commit is contained in:
parent
d3bc3da873
commit
62baf25f0b
1 changed files with 1 additions and 1 deletions
|
@ -123,7 +123,7 @@ static size_t find_largest_image(ICOLoadingContext const& context)
|
|||
size_t index = 0;
|
||||
size_t largest_index = 0;
|
||||
for (auto const& desc : context.images) {
|
||||
if (desc.width * desc.height > max_area) {
|
||||
if (static_cast<size_t>(desc.width) * static_cast<size_t>(desc.height) > max_area) {
|
||||
max_area = desc.width * desc.height;
|
||||
largest_index = index;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue