Skip to content

Commit cc15eb5

Browse files
committed
Fixed segfault in Zend/tests/008.phpt
1 parent b917458 commit cc15eb5

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Zend/zend_gc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ END_EXTERN_C()
140140
} \
141141
} while (0)
142142

143+
#define GC_REMOVE_ZOBJ_FROM_BUFFER(z) do { \
144+
if (GC_ADDRESS((z)->gc.u.v.buffer)) { \
145+
gc_remove_zval_from_buffer(&(z)->gc TSRMLS_CC); \
146+
} \
147+
} while (0)
148+
143149
static zend_always_inline void gc_zval_check_possible_root(zval *z TSRMLS_DC)
144150
{
145151
if (Z_TYPE_P(z) == IS_ARRAY || Z_TYPE_P(z) == IS_OBJECT) {

Zend/zend_objects_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
5555
obj->gc.refcount--;
5656

5757
if (obj->gc.refcount == 0) {
58-
gc_remove_zval_from_buffer((zend_refcounted*)obj TSRMLS_CC);
58+
GC_REMOVE_ZOBJ_FROM_BUFFER(obj TSRMLS_CC);
5959
}
6060
}
6161
}
@@ -86,7 +86,7 @@ ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects
8686
zend_object *obj = objects->object_buckets[i];
8787

8888
if (IS_VALID(obj)) {
89-
gc_remove_zval_from_buffer((zend_refcounted*)obj TSRMLS_CC);
89+
GC_REMOVE_ZOBJ_FROM_BUFFER(obj TSRMLS_CC);
9090
objects->object_buckets[i] = SET_INVALID(obj);
9191
if (obj->handlers->free_obj) {
9292
obj->handlers->free_obj(obj TSRMLS_CC);

0 commit comments

Comments
 (0)