diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-02-25 11:38:52 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-02-25 13:31:26 +0100 |
commit | ec6719fd25ebd49c43142a607353bad5df7874aa (patch) | |
tree | 2389a7b253258438ecf9b79f47364aaa257a8df2 | |
parent | b5e937397c27d522dcedc17647ad75e88f0f5027 (diff) | |
download | qpdf-ec6719fd25ebd49c43142a607353bad5df7874aa.tar.zst |
Always call dereference() before querying obj pointer
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 3a7bb2f9..c650bdea 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -326,6 +326,8 @@ QPDFObjectHandle::isBool() bool QPDFObjectHandle::isDirectNull() const { + // Don't call dereference() -- this is a const method, and we know + // objid == 0, so there's nothing to resolve. return (this->initialized && (this->objid == 0) && QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer())); } @@ -2452,6 +2454,8 @@ QPDFObjectHandle::getParsedOffset() void QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset) { + // This is called during parsing on newly created direct objects, + // so we can't call dereference() here. if (this->obj.getPointer()) { this->obj->setParsedOffset(offset); @@ -2694,6 +2698,8 @@ void QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, std::string const& object_description) { + // This is called during parsing on newly created direct objects, + // so we can't call dereference() here. if (isInitialized() && this->obj.getPointer()) { this->obj->setDescription(owning_qpdf, object_description); @@ -2703,9 +2709,13 @@ QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, bool QPDFObjectHandle::hasObjectDescription() { - if (isInitialized() && this->obj.getPointer()) + if (isInitialized()) { - return this->obj->hasDescription(); + dereference(); + if (this->obj.getPointer()) + { + return this->obj->hasDescription(); + } } return false; } |