Commit ec6719fd25ebd49c43142a607353bad5df7874aa
1 parent
b5e93739
Always call dereference() before querying obj pointer
Showing
1 changed file
with
12 additions
and
2 deletions
libqpdf/QPDFObjectHandle.cc
| @@ -326,6 +326,8 @@ QPDFObjectHandle::isBool() | @@ -326,6 +326,8 @@ QPDFObjectHandle::isBool() | ||
| 326 | bool | 326 | bool |
| 327 | QPDFObjectHandle::isDirectNull() const | 327 | QPDFObjectHandle::isDirectNull() const |
| 328 | { | 328 | { |
| 329 | + // Don't call dereference() -- this is a const method, and we know | ||
| 330 | + // objid == 0, so there's nothing to resolve. | ||
| 329 | return (this->initialized && (this->objid == 0) && | 331 | return (this->initialized && (this->objid == 0) && |
| 330 | QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer())); | 332 | QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer())); |
| 331 | } | 333 | } |
| @@ -2452,6 +2454,8 @@ QPDFObjectHandle::getParsedOffset() | @@ -2452,6 +2454,8 @@ QPDFObjectHandle::getParsedOffset() | ||
| 2452 | void | 2454 | void |
| 2453 | QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset) | 2455 | QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset) |
| 2454 | { | 2456 | { |
| 2457 | + // This is called during parsing on newly created direct objects, | ||
| 2458 | + // so we can't call dereference() here. | ||
| 2455 | if (this->obj.getPointer()) | 2459 | if (this->obj.getPointer()) |
| 2456 | { | 2460 | { |
| 2457 | this->obj->setParsedOffset(offset); | 2461 | this->obj->setParsedOffset(offset); |
| @@ -2694,6 +2698,8 @@ void | @@ -2694,6 +2698,8 @@ void | ||
| 2694 | QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, | 2698 | QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, |
| 2695 | std::string const& object_description) | 2699 | std::string const& object_description) |
| 2696 | { | 2700 | { |
| 2701 | + // This is called during parsing on newly created direct objects, | ||
| 2702 | + // so we can't call dereference() here. | ||
| 2697 | if (isInitialized() && this->obj.getPointer()) | 2703 | if (isInitialized() && this->obj.getPointer()) |
| 2698 | { | 2704 | { |
| 2699 | this->obj->setDescription(owning_qpdf, object_description); | 2705 | this->obj->setDescription(owning_qpdf, object_description); |
| @@ -2703,9 +2709,13 @@ QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, | @@ -2703,9 +2709,13 @@ QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf, | ||
| 2703 | bool | 2709 | bool |
| 2704 | QPDFObjectHandle::hasObjectDescription() | 2710 | QPDFObjectHandle::hasObjectDescription() |
| 2705 | { | 2711 | { |
| 2706 | - if (isInitialized() && this->obj.getPointer()) | 2712 | + if (isInitialized()) |
| 2707 | { | 2713 | { |
| 2708 | - return this->obj->hasDescription(); | 2714 | + dereference(); |
| 2715 | + if (this->obj.getPointer()) | ||
| 2716 | + { | ||
| 2717 | + return this->obj->hasDescription(); | ||
| 2718 | + } | ||
| 2709 | } | 2719 | } |
| 2710 | return false; | 2720 | return false; |
| 2711 | } | 2721 | } |