summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-03-22 12:11:01 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-22 12:14:09 +0100
commitd195972ec250c87aa0a3d032aec9dc4544db7a10 (patch)
tree8d00bfb8f691779aa59052b93ea03429949a175c /Userland/Applications/PixelPaint
parent1db7c423db6a2f90bf86d79fd2d533a155aecb0d (diff)
downloadserenity-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.cpp6
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)