From 264d4082e447568492ed7a38be860a3e562427f0 Mon Sep 17 00:00:00 2001 From: m-holger Date: Thu, 7 Nov 2024 13:49:41 +0000 Subject: [PATCH] Fix QPDF::copyForeignObject warning Provide correct obj_gen and offset. --- libqpdf/QPDF.cc | 7 +++++-- qpdf/qtest/qpdf/copy-foreign-objects-25.out | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index cc54db29..a9b483ac 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -677,8 +677,11 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign) auto og = foreign.getObjGen(); if (!obj_copier.object_map.count(og)) { - warn(damagedPDF("unexpected reference to /Pages object while copying foreign object; " - "replacing with null")); + warn(damagedPDF( + "foreign object " + og.unparse(' '), + foreign.getParsedOffset(), + "unexpected reference to /Pages object while copying foreign object; replacing with " + "null")); return QPDFObjectHandle::newNull(); } return obj_copier.object_map[foreign.getObjGen()]; diff --git a/qpdf/qtest/qpdf/copy-foreign-objects-25.out b/qpdf/qtest/qpdf/copy-foreign-objects-25.out index 36b5bb0d..4e86eadf 100644 --- a/qpdf/qtest/qpdf/copy-foreign-objects-25.out +++ b/qpdf/qtest/qpdf/copy-foreign-objects-25.out @@ -1,2 +1,2 @@ -WARNING: minimal.pdf (object 6 0, offset 556): unexpected reference to /Pages object while copying foreign object; replacing with null +WARNING: minimal.pdf (foreign object 2 0, offset 768): unexpected reference to /Pages object while copying foreign object; replacing with null test 25 done