summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2010-06-06 20:03:21 +0200
committerJay Berkenbilt <ejb@ql.org>2010-06-06 20:03:21 +0200
commit6755a86734176caa1a3c38ad6db5bc3a01be8505 (patch)
tree08e1c6e0a4e1e142894806f4966f8e14a6e05c36 /libqpdf/QPDF.cc
parent21753001b701ed2d3f48f73c1a2733b3a337fc99 (diff)
downloadqpdf-6755a86734176caa1a3c38ad6db5bc3a01be8505.tar.zst
comment on memory leak fix
git-svn-id: svn+q:///qpdf/trunk@979 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index f68efc83..cbc2450c 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -277,6 +277,20 @@ QPDF::QPDF() :
QPDF::~QPDF()
{
+ // If two objects are mutually referential (through each object
+ // having an array or dictionary that contains an indirect
+ // reference to the other), the circular references in the
+ // PointerHolder 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 references. 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. If we do, the next
+ // reference will reread the object from the file, which would
+ // have the effect of undoing any modifications that may have been
+ // made to any of the objects.
this->xref_table.clear();
for (std::map<ObjGen, ObjCache>::iterator iter = this->obj_cache.begin();
iter != obj_cache.end(); ++iter)