From e4e0f40fc0b9fe74865898b640ff82f84996bb5d Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 9 Jan 2023 07:31:39 -0500 Subject: Fix annotations properly for page with no /Resources (fixes #827) --- libqpdf/QPDFPageDocumentHelper.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc index 39b2800a..31d84e4b 100644 --- a/libqpdf/QPDFPageDocumentHelper.cc +++ b/libqpdf/QPDFPageDocumentHelper.cc @@ -67,9 +67,11 @@ QPDFPageDocumentHelper::flattenAnnotations( for (auto& ph: getAllPages()) { QPDFObjectHandle resources = ph.getAttribute("/Resources", true); if (!resources.isDictionary()) { - // This should never happen and is not exercised in the - // test suite - resources = QPDFObjectHandle::newDictionary(); + QTC::TC( + "qpdf", + "QPDFPageDocumentHelper flatten resources missing or invalid"); + resources = ph.getObjectHandle().replaceKeyAndGetNew( + "/Resources", QPDFObjectHandle::newDictionary()); } flattenAnnotationsForPage( ph, resources, afdh, required_flags, forbidden_flags); -- cgit v1.2.3-70-g09d2