From ca79fcb26e1e1fa94bd1119119eac17b5140c196 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sun, 3 Sep 2023 10:50:06 +0100 Subject: Add test for attempts to copy foreign /Pages object --- qpdf/qtest/qpdf/copy-foreign-objects-25.out | 1 + qpdf/test_driver.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/qpdf/qtest/qpdf/copy-foreign-objects-25.out b/qpdf/qtest/qpdf/copy-foreign-objects-25.out index da8906a7..a34184ac 100644 --- a/qpdf/qtest/qpdf/copy-foreign-objects-25.out +++ b/qpdf/qtest/qpdf/copy-foreign-objects-25.out @@ -1 +1,2 @@ +WARNING: minimal.pdf (object 6 0, offset 556): Unexpected reference to /Pages object while copying foreign object. Replacing with Null object. test 25 done diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index b2ed825d..2e661fdb 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -954,6 +954,8 @@ test_25(QPDF& pdf, char const* arg2) // Copy qtest without crossing page boundaries. Should get O1 // and O2 and their streams but not O3 or any other pages. + // Also verify that attempts to copy /Pages objects return null. + assert(arg2 != nullptr); { // Make sure original PDF is out of scope when we write. @@ -961,6 +963,8 @@ test_25(QPDF& pdf, char const* arg2) oldpdf.processFile(arg2); QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest"); pdf.getTrailer().replaceKey("/QTest", pdf.copyForeignObject(qtest)); + + assert(pdf.copyForeignObject(oldpdf.getRoot().getKey("/Pages")).isNull()); } QPDFWriter w(pdf, "a.pdf"); -- cgit v1.2.3-54-g00ecf