From 8fb9d1fd1dbe95f7ef2d8fa96eb0534afc51bee0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Feb 2021 11:33:34 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibImageDecoderClient/Client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibImageDecoderClient/Client.cpp b/Userland/Libraries/LibImageDecoderClient/Client.cpp index 29455ef47bc..5ac14c63b1d 100644 --- a/Userland/Libraries/LibImageDecoderClient/Client.cpp +++ b/Userland/Libraries/LibImageDecoderClient/Client.cpp @@ -56,7 +56,12 @@ Optional Client::decode_image(const ByteBuffer& encoded_data) } memcpy(encoded_buffer.data(), encoded_data.data(), encoded_data.size()); - auto response = send_sync(move(encoded_buffer)); + auto response = send_sync_but_allow_failure(move(encoded_buffer)); + + if (!response) { + dbgln("ImageDecoder died heroically"); + return {}; + } DecodedImage image; image.is_animated = response->is_animated();