diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-02-25 12:34:03 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-02-25 13:32:46 +0100 |
commit | a4d6589ff26007c966db8912e4dae1aa937a5968 (patch) | |
tree | 7eeba29b6e1b59a69f9e60105c1de4b587246473 /libqpdf/QPDFObjectHandle.cc | |
parent | ec6719fd25ebd49c43142a607353bad5df7874aa (diff) | |
download | qpdf-a4d6589ff26007c966db8912e4dae1aa937a5968.tar.zst |
Have QPDFObjectHandle notice when replaceObject was called
This results in a performance penalty of 1% to 2% when replaceObject
and swapObjects are never called and a somewhat larger penalty if they
are called, but it's worth it to avoid very confusing behavior as
discussed in depth in qpdf#507.
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index c650bdea..6d4f10ce 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -3194,6 +3194,12 @@ QPDFObjectHandle::dereference() throw std::logic_error( "attempted to dereference an uninitialized QPDFObjectHandle"); } + if (this->obj.getPointer() && this->objid && + QPDF::Resolver::objectChanged( + this->qpdf, QPDFObjGen(this->objid, this->generation), this->obj)) + { + this->obj = nullptr; + } if (this->obj.getPointer() == 0) { PointerHolder<QPDFObject> obj = QPDF::Resolver::resolve( |