summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-20 11:33:34 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-20 11:37:55 +0100
commit8fb9d1fd1dbe95f7ef2d8fa96eb0534afc51bee0 (patch)
treef430324a7bacaaa08a32c5c40e889cbe98f5f5b4 /Userland/Libraries
parenta446cea75909a9571191f1c45e7bb4ba91b7df23 (diff)
downloadserenity-8fb9d1fd1dbe95f7ef2d8fa96eb0534afc51bee0.zip
LibImageDecoderClient: Gracefully recover from decoder crashes :^)
If the ImageDecoder service crashes while decoding an image for us, we now recover gracefully and simply return null. This shields the browser from bugs in our image decoders.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibImageDecoderClient/Client.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibImageDecoderClient/Client.cpp b/Userland/Libraries/LibImageDecoderClient/Client.cpp
index 29455ef47b..5ac14c63b1 100644
--- a/Userland/Libraries/LibImageDecoderClient/Client.cpp
+++ b/Userland/Libraries/LibImageDecoderClient/Client.cpp
@@ -56,7 +56,12 @@ Optional<DecodedImage> Client::decode_image(const ByteBuffer& encoded_data)
}
memcpy(encoded_buffer.data<void>(), encoded_data.data(), encoded_data.size());
- auto response = send_sync<Messages::ImageDecoderServer::DecodeImage>(move(encoded_buffer));
+ auto response = send_sync_but_allow_failure<Messages::ImageDecoderServer::DecodeImage>(move(encoded_buffer));
+
+ if (!response) {
+ dbgln("ImageDecoder died heroically");
+ return {};
+ }
DecodedImage image;
image.is_animated = response->is_animated();