浏览代码

ImageDecoder: Fix assertion after failed decode

We were calling value() on an ErrorOr containing an error when trying
to extract the frame duration after a failed decode.

This fixes ImageDecoder crashing on various websites.
Andreas Kling 3 年之前
父节点
当前提交
da42c1552c
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      Userland/Services/ImageDecoder/ClientConnection.cpp

+ 7 - 4
Userland/Services/ImageDecoder/ClientConnection.cpp

@@ -53,11 +53,14 @@ Messages::ImageDecoderServer::DecodeImageResponse ClientConnection::decode_image
     Vector<u32> durations;
     for (size_t i = 0; i < decoder->frame_count(); ++i) {
         auto frame_or_error = decoder->frame(i);
-        if (frame_or_error.is_error() || !frame_or_error.value().image)
+        if (frame_or_error.is_error()) {
             bitmaps.append(Gfx::ShareableBitmap {});
-        else
-            bitmaps.append(frame_or_error.value().image->to_shareable_bitmap());
-        durations.append(frame_or_error.value().duration);
+            durations.append(0);
+        } else {
+            auto frame = frame_or_error.release_value();
+            bitmaps.append(frame.image->to_shareable_bitmap());
+            durations.append(frame.duration);
+        }
     }
 
     return { decoder->is_animated(), static_cast<u32>(decoder->loop_count()), bitmaps, durations };