mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
Applications: Do not crash if decoded bitmap is null
ImageViewer and PixelPaint would crash when the ImageDecoderClient returns a frame without a bitmap. This can happen with `.ico` files with an unsupported BPP, for example.
This commit is contained in:
parent
1db7c423db
commit
d195972ec2
2 changed files with 10 additions and 1 deletions
|
@ -67,7 +67,11 @@ ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Image::try_decode_bitmap(ReadonlyBytes bitma
|
|||
auto decoded_image = maybe_decoded_image.release_value();
|
||||
if (decoded_image.frames.is_empty())
|
||||
return Error::from_string_literal("Image decode failed (no frames)"sv);
|
||||
return decoded_image.frames[0].bitmap.release_nonnull();
|
||||
|
||||
auto decoded_bitmap = decoded_image.frames.first().bitmap;
|
||||
if (decoded_bitmap.is_null())
|
||||
return Error::from_string_literal("Image decode failed (no bitmap for frame)"sv);
|
||||
return decoded_bitmap.release_nonnull();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Image>> Image::try_create_from_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue