diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-03-22 12:11:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-22 12:14:09 +0100 |
commit | d195972ec250c87aa0a3d032aec9dc4544db7a10 (patch) | |
tree | 8d00bfb8f691779aa59052b93ea03429949a175c /Userland/Applications/PixelPaint | |
parent | 1db7c423db6a2f90bf86d79fd2d533a155aecb0d (diff) | |
download | serenity-d195972ec250c87aa0a3d032aec9dc4544db7a10.zip |
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.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r-- | Userland/Applications/PixelPaint/Image.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 7ca784a218..a14246b08e 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -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) |