mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +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
Notes:
sideshowbarker
2024-07-19 00:39:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/80ae407d739
1 changed files with 2 additions and 7 deletions
|
@ -336,7 +336,7 @@ static u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data)
|
|||
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())
|
||||
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.mask_shifts.append({ 7, 2, -3 });
|
||||
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)) {
|
||||
// Consume the extra BITFIELDS bytes
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue