summaryrefslogtreecommitdiff
path: root/zend/objectimpl.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-12-16 12:47:11 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-12-16 12:47:11 +0100
commitff9a22782a7d28b11af0ff2d3948a196ab12d003 (patch)
tree3fcb8020cb0dce094abefbbecb83055fc31ed1fd /zend/objectimpl.h
parentda4de6cb1097471b2659c102d55a646cbc9e0f41 (diff)
fix issue #151, chaining method calls was not working as it should because the per-object refcount was not updated correctly, which caused an object to be destructed even when it already was assigned to a different variable
Diffstat (limited to 'zend/objectimpl.h')
-rw-r--r--zend/objectimpl.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/zend/objectimpl.h b/zend/objectimpl.h
index d72ddbd..4d20f3c 100644
--- a/zend/objectimpl.h
+++ b/zend/objectimpl.h
@@ -62,9 +62,10 @@ public:
*
* @param entry Zend class entry
* @param base C++ object that already exists
+ * @param refcount The initial refcount for the object
* @param tsrm_ls Optional threading data
*/
- ObjectImpl(zend_class_entry *entry, Base *base TSRMLS_DC)
+ ObjectImpl(zend_class_entry *entry, Base *base, int refcount TSRMLS_DC)
{
// allocate a mixed object (for some reason this does not have to be deallocated)
_mixed = (MixedObject *)emalloc(sizeof(MixedObject));
@@ -117,6 +118,9 @@ public:
// seem to be necessary...
_handle = zend_objects_store_put(php(), (zend_objects_store_dtor_t)destructMethod, (zend_objects_free_object_storage_t)freeMethod, NULL TSRMLS_CC);
+ // set the initial refcount (if it is different than one, because one is the default)
+ if (refcount != 1) EG(objects_store).object_buckets[_handle].bucket.obj.refcount = refcount;
+
// the object may remember that we are its implementation object
base->_impl = this;
}