LibPDF: Make JPEG decoding errors not assert

Instead, they're now turned into a diagnostic like other rendering
problems, looking like so:

    Internal error while processing PDF file:
        Unsupported chroma subsampling factors

Makes us no longer crash rendering page 1141 of pdf_reference_1.7-pdf.
This commit is contained in:
Nico Weber 2023-07-23 21:02:08 -04:00 committed by Tim Flynn
parent d6ddc25975
commit 7dfa5fc1dc
Notes: sideshowbarker 2024-07-16 23:08:48 +09:00

View File

@ -271,7 +271,7 @@ PDFErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
PDFErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
{
if (Gfx::JPEGImageDecoderPlugin::sniff({ bytes.data(), bytes.size() })) {
auto decoder = Gfx::JPEGImageDecoderPlugin::create({ bytes.data(), bytes.size() }).release_value_but_fixme_should_propagate_errors();
auto decoder = TRY(Gfx::JPEGImageDecoderPlugin::create({ bytes.data(), bytes.size() }));
auto frame = TRY(decoder->frame(0));
return TRY(frame.image->serialize_to_byte_buffer());
}