aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-09-07 22:49:31 +0200
committerJay Berkenbilt <ejb@ql.org>2022-09-08 16:19:38 +0200
commit264e25f391f83bcbeb60590f18ff96719b086454 (patch)
treead7a6daae5a2350d56a521eb022fea30e799b95c /libqpdf/QPDF.cc
parenta615985865ca73249a7b21e2f28b440cb6c16636 (diff)
downloadqpdf-264e25f391f83bcbeb60590f18ff96719b086454.tar.zst
Clear owning QPDF information for all objects, not just indirect
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 9764cf70..40390055 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -247,19 +247,24 @@ QPDF::~QPDF()
// having an array or dictionary that contains an indirect
// reference to the other), the circular references in the
// std::shared_ptr objects will prevent the objects from being
- // deleted. Walk through all objects in the object cache, which
- // is those objects that we read from the file, and break all
- // resolved indirect references by replacing them with direct
- // null objects. At this point, obviously no one is still
- // using the QPDF object, but we'll explicitly clear the xref
- // table anyway just to prevent any possibility of resolve()
- // succeeding. Note that we can't break references like this at
- // any time when the QPDF object is active.
+ // deleted. Walk through all objects in the object cache, which is
+ // those objects that we read from the file, and break all
+ // resolved indirect references by replacing them with direct null
+ // objects. At this point, obviously no one is still using the
+ // QPDF object, but we'll explicitly clear the xref table anyway
+ // just to prevent any possibility of resolve() succeeding. Note
+ // that we can't break references like this at any time when the
+ // QPDF object is active. This also causes all QPDFObjectHandle
+ // objects that are reachable from this object to become nulls and
+ // release their association with this QPDF.
this->m->xref_table.clear();
auto null_obj = QPDF_Null::create();
for (auto const& iter: this->m->obj_cache) {
+ iter.second.object->reset();
+ // If the issue discussed in QPDFValueProxy::reset were
+ // resolved, then this assignment to null_obj could be
+ // removed.
iter.second.object->assign(null_obj);
- iter.second.object->resetObjGen();
}
}