Commit ca79fcb26e1e1fa94bd1119119eac17b5140c196

Authored by m-holger
1 parent 0046de08

Add test for attempts to copy foreign /Pages object

qpdf/qtest/qpdf/copy-foreign-objects-25.out
  1 +WARNING: minimal.pdf (object 6 0, offset 556): Unexpected reference to /Pages object while copying foreign object. Replacing with Null object.
1 2 test 25 done
... ...
qpdf/test_driver.cc
... ... @@ -954,6 +954,8 @@ test_25(QPDF& pdf, char const* arg2)
954 954 // Copy qtest without crossing page boundaries. Should get O1
955 955 // and O2 and their streams but not O3 or any other pages.
956 956  
  957 + // Also verify that attempts to copy /Pages objects return null.
  958 +
957 959 assert(arg2 != nullptr);
958 960 {
959 961 // Make sure original PDF is out of scope when we write.
... ... @@ -961,6 +963,8 @@ test_25(QPDF& pdf, char const* arg2)
961 963 oldpdf.processFile(arg2);
962 964 QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
963 965 pdf.getTrailer().replaceKey("/QTest", pdf.copyForeignObject(qtest));
  966 +
  967 + assert(pdf.copyForeignObject(oldpdf.getRoot().getKey("/Pages")).isNull());
964 968 }
965 969  
966 970 QPDFWriter w(pdf, "a.pdf");
... ...