From 25e11a444a25840e2b4635dbcb0197d5bb935d25 Mon Sep 17 00:00:00 2001 From: m-holger Date: Tue, 16 Jul 2024 14:44:47 +0100 Subject: [PATCH] Throw an exception if the root of the pages tree misses the /Kids array --- libqpdf/QPDF_pages.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc index 8c6a20e7..0c8f3829 100644 --- a/libqpdf/QPDF_pages.cc +++ b/libqpdf/QPDF_pages.cc @@ -66,10 +66,12 @@ QPDF::getAllPages() getRoot().replaceKey("/Pages", pages); } seen.clear(); - if (pages.hasKey("/Kids")) { + if (!pages.hasKey("/Kids")) { // Ensure we actually found a /Pages object. - getAllPagesInternal(pages, visited, seen, false); + throw QPDFExc( + qpdf_e_pages, m->file->getName(), "", 0, "root of pages tree has no /Kids array"); } + getAllPagesInternal(pages, visited, seen, false); if (m->invalid_page_found) { flattenPagesTree(); m->invalid_page_found = false;