From 6d47fca3bfd8e8b8d5c8a52103277350e78c14e4 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 24 Oct 2023 23:45:46 -0700 Subject: [PATCH] LibPDF: Don't assert on outline destinations that use `null` as page Nothing in PDF 1.7 spec 8.2.1 Destinations mentions the page being `null`, but it happens in 0000372.pdf (for the root outline element) and in 0000776.pdf (for every outline element, which looks like a bug in the generator maybe) of 0000.zip from the pdfa dataset. --- Userland/Libraries/LibPDF/Document.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibPDF/Document.cpp b/Userland/Libraries/LibPDF/Document.cpp index 6bda120e87..5b73431530 100644 --- a/Userland/Libraries/LibPDF/Document.cpp +++ b/Userland/Libraries/LibPDF/Document.cpp @@ -418,6 +418,10 @@ PDFErrorOr Document::build_outline() PDFErrorOr Document::create_destination_from_parameters(NonnullRefPtr array, HashMap const& page_number_by_index_ref) { auto page_ref = array->at(0); + + if (page_ref.has()) + return Destination { Destination::Type::XYZ, {}, {} }; + auto type_name = TRY(array->get_name_at(this, 1))->name(); Vector> parameters;