mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGfx: Always compute the DIB mask shifts and sizes if needed
The pixel decoding logic later on assumes that if we have DIB masks, we also have shifts and sizes, so we should make sure they are always computed. Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28237
This commit is contained in:
parent
cd046fae44
commit
80ae407d73
|
@ -336,7 +336,7 @@ static u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data)
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void populate_dib_mask_info(BMPLoadingContext& context)
|
static void populate_dib_mask_info_if_needed(BMPLoadingContext& context)
|
||||||
{
|
{
|
||||||
if (context.dib.info.masks.is_empty())
|
if (context.dib.info.masks.is_empty())
|
||||||
return;
|
return;
|
||||||
|
@ -439,8 +439,6 @@ static bool set_dib_bitmasks(BMPLoadingContext& context, Streamer& streamer)
|
||||||
context.dib.info.masks.append({ 0x7c00, 0x03e0, 0x001f });
|
context.dib.info.masks.append({ 0x7c00, 0x03e0, 0x001f });
|
||||||
context.dib.info.mask_shifts.append({ 7, 2, -3 });
|
context.dib.info.mask_shifts.append({ 7, 2, -3 });
|
||||||
context.dib.info.mask_sizes.append({ 5, 5, 5 });
|
context.dib.info.mask_sizes.append({ 5, 5, 5 });
|
||||||
|
|
||||||
populate_dib_mask_info(context);
|
|
||||||
} else if (type == DIBType::Info && (compression == Compression::BITFIELDS || compression == Compression::ALPHABITFIELDS)) {
|
} else if (type == DIBType::Info && (compression == Compression::BITFIELDS || compression == Compression::ALPHABITFIELDS)) {
|
||||||
// Consume the extra BITFIELDS bytes
|
// Consume the extra BITFIELDS bytes
|
||||||
auto number_of_mask_fields = compression == Compression::ALPHABITFIELDS ? 4 : 3;
|
auto number_of_mask_fields = compression == Compression::ALPHABITFIELDS ? 4 : 3;
|
||||||
|
@ -450,12 +448,9 @@ static bool set_dib_bitmasks(BMPLoadingContext& context, Streamer& streamer)
|
||||||
return false;
|
return false;
|
||||||
context.dib.info.masks.append(streamer.read_u32());
|
context.dib.info.masks.append(streamer.read_u32());
|
||||||
}
|
}
|
||||||
|
|
||||||
populate_dib_mask_info(context);
|
|
||||||
} else if (type >= DIBType::V2 && compression == Compression::BITFIELDS) {
|
|
||||||
populate_dib_mask_info(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populate_dib_mask_info_if_needed(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue