Skip to content

Commit 4e2c0bc

Browse files
committed
MFH: fix bug #47353 (crash when creating a lot of objects in object destructor)
1 parent 3419a46 commit 4e2c0bc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_objects_API.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
5555
if (obj->dtor && obj->object) {
5656
obj->refcount++;
5757
obj->dtor(obj->object, i TSRMLS_CC);
58+
obj = &objects->object_buckets[i].bucket.obj;
5859
obj->refcount--;
5960
}
6061
}
@@ -208,6 +209,10 @@ ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle,
208209
} zend_end_try();
209210
}
210211
}
212+
213+
/* re-read the object from the object store as the store might have been reallocated in the dtor */
214+
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
215+
211216
if (obj->refcount == 1) {
212217
GC_REMOVE_ZOBJ_FROM_BUFFER(obj);
213218
if (obj->free_storage) {
@@ -251,6 +256,7 @@ ZEND_API zend_object_value zend_objects_store_clone_obj(zval *zobject TSRMLS_DC)
251256
}
252257

253258
obj->clone(obj->object, &new_object TSRMLS_CC);
259+
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
254260

255261
retval.handle = zend_objects_store_put(new_object, obj->dtor, obj->free_storage, obj->clone TSRMLS_CC);
256262
retval.handlers = Z_OBJ_HT_P(zobject);

0 commit comments

Comments
 (0)