]> granicus.if.org Git - php/commitdiff
Fixed segfault in Zend/tests/008.phpt
authorXinchen Hui <laruence@gmail.com>
Thu, 20 Feb 2014 08:21:41 +0000 (16:21 +0800)
committerXinchen Hui <laruence@gmail.com>
Thu, 20 Feb 2014 08:21:41 +0000 (16:21 +0800)
Zend/zend_gc.h
Zend/zend_objects_API.c

index 2f3a399c992359d40eea606e928f2b40facd5de8..f714033962e0a6323d6ed427bb642e465465032c 100644 (file)
@@ -140,6 +140,12 @@ END_EXTERN_C()
                } \
        } while (0)
 
+#define GC_REMOVE_ZOBJ_FROM_BUFFER(z) do { \
+               if (GC_ADDRESS((z)->gc.u.v.buffer)) { \
+                       gc_remove_zval_from_buffer(&(z)->gc TSRMLS_CC); \
+               } \
+       } while (0)
+
 static zend_always_inline void gc_zval_check_possible_root(zval *z TSRMLS_DC)
 {
        if (Z_TYPE_P(z) == IS_ARRAY || Z_TYPE_P(z) == IS_OBJECT) {
index 5bef2d49733900966ecb42c93e7d1ed27729bf3a..8e406ec71540df72dddf8b9cf194a5cc73d9d139 100644 (file)
@@ -55,7 +55,7 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TS
                                obj->gc.refcount--;
 
                                if (obj->gc.refcount == 0) {
-                                       gc_remove_zval_from_buffer((zend_refcounted*)obj TSRMLS_CC);
+                                       GC_REMOVE_ZOBJ_FROM_BUFFER(obj TSRMLS_CC);
                                }
                        }
                }
@@ -86,7 +86,7 @@ ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects
                zend_object *obj = objects->object_buckets[i];
 
                if (IS_VALID(obj)) {
-                       gc_remove_zval_from_buffer((zend_refcounted*)obj TSRMLS_CC);
+                       GC_REMOVE_ZOBJ_FROM_BUFFER(obj TSRMLS_CC);
                        objects->object_buckets[i] = SET_INVALID(obj);
                        if (obj->handlers->free_obj) {
                                obj->handlers->free_obj(obj TSRMLS_CC);