From 413c8c0f924f387bf5bbfb208ba4be34db4d1265 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sun, 27 Jul 2025 17:35:48 +0100 Subject: [PATCH] Enhance `QPDFParser` sanity checks after xref recovery to include parsing of content streams. --- libqpdf/QPDFParser.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc index f671f64..0132f17 100644 --- a/libqpdf/QPDFParser.cc +++ b/libqpdf/QPDFParser.cc @@ -40,7 +40,16 @@ QPDFParser::parse_content( { bool empty = false; return QPDFParser( - input, std::move(sp_description), "content", tokenizer, nullptr, context, true) + input, + std::move(sp_description), + "content", + tokenizer, + nullptr, + context, + true, + 0, + 0, + context && context->reconstructed_xref()) .parse(empty, true); } @@ -623,7 +632,7 @@ QPDFParser::tooManyBadTokens() "encountered an array or dictionary with more than 5000 elements during xref recovery; " "giving up on reading object"); } - if (--max_bad_count > 0 && good_count > 4) { + if (max_bad_count && --max_bad_count > 0 && good_count > 4) { good_count = 0; bad_count = 1; return false; -- libgit2 0.21.4