1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibPDF: Don't crash on images with empty filter arrays

0000967.pdf page 2 contains a bunch of inline images with empty
filter arrays.
This commit is contained in:
Nico Weber 2023-12-19 19:30:13 -05:00 committed by Andreas Kling
parent 13641693cb
commit b21f867e88

View file

@ -890,6 +890,8 @@ PDFErrorOr<NonnullRefPtr<Gfx::Bitmap>> Renderer::load_image(NonnullRefPtr<Stream
if (filter_object->is<NameObject>())
return filter_object->cast<NameObject>()->name() == name;
auto filters = filter_object->cast<ArrayObject>();
if (filters->elements().is_empty())
return false;
auto last_filter_index = filters->elements().size() - 1;
return MUST(filters->get_name_at(m_document, last_filter_index))->name() == name;
};