mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:17:45 +00:00
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.
This commit is contained in:
parent
dcc7d7d566
commit
da42c1552c
1 changed files with 7 additions and 4 deletions
|
@ -53,11 +53,14 @@ Messages::ImageDecoderServer::DecodeImageResponse ClientConnection::decode_image
|
||||||
Vector<u32> durations;
|
Vector<u32> durations;
|
||||||
for (size_t i = 0; i < decoder->frame_count(); ++i) {
|
for (size_t i = 0; i < decoder->frame_count(); ++i) {
|
||||||
auto frame_or_error = decoder->frame(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 {});
|
bitmaps.append(Gfx::ShareableBitmap {});
|
||||||
else
|
durations.append(0);
|
||||||
bitmaps.append(frame_or_error.value().image->to_shareable_bitmap());
|
} else {
|
||||||
durations.append(frame_or_error.value().duration);
|
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 };
|
return { decoder->is_animated(), static_cast<u32>(decoder->loop_count()), bitmaps, durations };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue