diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-09-08 14:03:57 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-09-08 16:36:39 +0200 |
commit | dba61da1bfb7e4d74c723f369d1c017df9707a14 (patch) | |
tree | 04c51f86dc066c710c23423fe178e051b20b49d9 /libqpdf/QPDFObjectHandle.cc | |
parent | 264e25f391f83bcbeb60590f18ff96719b086454 (diff) | |
download | qpdf-dba61da1bfb7e4d74c723f369d1c017df9707a14.tar.zst |
Create a special "destroyed" type rather than using null
When a QPDF is destroyed, changing indirect objects to direct nulls
makes them effectively disappear silently when they sneak into other
places. Instead, we should treat this as an error. Adding a destroyed
object type makes this possible.
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index fa8aae7f..556e3a1e 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -252,8 +252,10 @@ void QPDFObjectHandle::reset() { // Recursively remove association with any QPDF object. This - // method may only be called during final destruction. See - // comments in QPDF::~QPDF(). + // method may only be called during final destruction. + // QPDF::~QPDF() calls it for indirect objects using the object + // pointer itself, so we don't do that here. Other objects call it + // through this method. if (!isIndirect()) { this->obj->reset(); } @@ -352,6 +354,12 @@ QPDFObjectHandle::asString() } bool +QPDFObjectHandle::isDestroyed() +{ + return dereference() && (obj->getTypeCode() == ::ot_destroyed); +} + +bool QPDFObjectHandle::isBool() { return dereference() && (obj->getTypeCode() == ::ot_boolean); |