aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFWriter.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-09-08 17:06:15 +0200
committerJay Berkenbilt <ejb@ql.org>2022-09-08 17:06:15 +0200
commitc7a4967d10fb9688f235baa8e57a1fb578f5387d (patch)
treeb14956a2371befbd30b2a43583c390bc170ccd3d /libqpdf/QPDFWriter.cc
parentdba61da1bfb7e4d74c723f369d1c017df9707a14 (diff)
downloadqpdf-c7a4967d10fb9688f235baa8e57a1fb578f5387d.tar.zst
Change reset to disconnect and clarify comments
I decided that it's actually fine to copy a direct object to another QPDF. Even if we eventually prevent a QPDFObject from having multiple parents, this could happen if an object is moved.
Diffstat (limited to 'libqpdf/QPDFWriter.cc')
-rw-r--r--libqpdf/QPDFWriter.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index 83785465..aad536b0 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -1198,14 +1198,12 @@ void
QPDFWriter::enqueueObject(QPDFObjectHandle object)
{
if (object.isIndirect()) {
- // This owner check should really be done for all objects, not
- // just indirect objects. As of the time of the release of
- // qpdf 11, it is known that there are cases of direct objects
- // from other files getting copied into multiple QPDF objects.
- // This definitely happens in the page splitting code. If we
- // were to implement strong checks to prevent objects from
- // having multiple owners, once that was complete phased in,
- // this check could be moved outside the if statement.
+ // This owner check can only be done for indirect objects. It
+ // is possible for a direct object to have an owning QPDF that
+ // is from another file if a direct QPDFObjectHandle from one
+ // file was insert into another file without copying. Doing
+ // that is safe even if the original QPDF gets destroyed,
+ // which just disconnects the QPDFObjectHandle from its owner.
if (object.getOwningQPDF() != &(this->m->pdf)) {
QTC::TC("qpdf", "QPDFWriter foreign object");
throw std::logic_error(