diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp index 6be4afa916..38df8fb0db 100644 --- a/Userland/Libraries/LibPDF/Parser.cpp +++ b/Userland/Libraries/LibPDF/Parser.cpp @@ -303,7 +303,7 @@ PDFErrorOr> Parser::parse_xref_table() auto table = adopt_ref(*new XRefTable()); - while (true) { + do { if (m_reader.matches("trailer")) return table; @@ -349,11 +349,16 @@ PDFErrorOr> Parser::parse_xref_table() } table->add_section({ starting_index, object_count, entries }); - } + } while (matches_number()); + + return table; } PDFErrorOr> Parser::parse_file_trailer() { + while (matches_eol()) + consume_eol(); + if (!m_reader.matches("trailer")) return error("Expected \"trailer\" keyword"); m_reader.move_by(7);