1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

LibGfx: Use ErrorOr<T> for Bitmap::try_create()

Another one that was used in a fajillion places.
This commit is contained in:
Andreas Kling 2021-11-06 19:30:59 +01:00
parent 235f39e449
commit 0de33b3d6c
43 changed files with 157 additions and 141 deletions

View file

@ -1187,12 +1187,15 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context)
const u32 width = abs(context.dib.core.width);
const u32 height = abs(context.dib.core.height);
context.bitmap = Bitmap::try_create(format, { static_cast<int>(width), static_cast<int>(height) });
if (!context.bitmap) {
dbgln("BMP appears to have overly large dimensions");
auto bitmap_or_error = Bitmap::try_create(format, { static_cast<int>(width), static_cast<int>(height) });
if (bitmap_or_error.is_error()) {
// FIXME: Propagate the *real* error.
return false;
}
context.bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
ByteBuffer rle_buffer;
ReadonlyBytes bytes { context.file_bytes + context.data_offset, context.file_size - context.data_offset };