diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-20 11:33:34 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-20 11:37:55 +0100 |
commit | 8fb9d1fd1dbe95f7ef2d8fa96eb0534afc51bee0 (patch) | |
tree | f430324a7bacaaa08a32c5c40e889cbe98f5f5b4 /Userland/Libraries | |
parent | a446cea75909a9571191f1c45e7bb4ba91b7df23 (diff) | |
download | serenity-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.cpp | 7 |
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(); |