diff options
author | Dmitry Stogov <dmitry@php.net> | 2010-08-11 09:38:41 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2010-08-11 09:38:41 +0000 |
commit | b6ffe2f92b7382d268f6f9114fff520e1ddd8270 (patch) | |
tree | d2528b326bd49ccffa91dcfb73f4344c8f3a5715 | |
parent | f810ef5359bc2ae9b37bae20c893090c7a60d5aa (diff) | |
download | php-git-b6ffe2f92b7382d268f6f9114fff520e1ddd8270.tar.gz |
In ZTS mode default properties and constants of internal classes can't be modified in place and have to be separated
-rw-r--r-- | Zend/zend_compile.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 551b385030..895fbbeb01 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2298,6 +2298,25 @@ static int inherit_static_prop(zval **p, int num_args, va_list args, zend_hash_k return ZEND_HASH_APPLY_KEEP; } +#ifdef ZTS +static void zval_internal_ctor(zval **p) +{ + zval *orig_ptr = *p; + + ALLOC_ZVAL(*p); + **p = *orig_ptr; + zval_copy_ctor(*p); + (*p)->refcount = 1; + (*p)->is_ref = 0; +} + +# define zval_property_ctor(parent_ce, ce) \ + ((void (*)(void *)) (((parent_ce)->type != (ce)->type) ? zval_internal_ctor : zval_add_ref)) +#else +# define zval_property_ctor(parent_ce, ce) \ + ((void (*)(void *)) zval_add_ref) +#endif + ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC) { if ((ce->ce_flags & ZEND_ACC_INTERFACE) @@ -2313,7 +2332,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent zend_do_inherit_interfaces(ce, parent_ce TSRMLS_CC); /* Inherit properties */ - zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0); + zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, zval_property_ctor(parent_ce, ce), NULL, sizeof(zval *), 0); if (parent_ce->type != ce->type) { /* User class extends internal class */ zend_update_class_constants(parent_ce TSRMLS_CC); @@ -2323,7 +2342,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent } zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce); - zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0); + zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, zval_property_ctor(parent_ce, ce), NULL, sizeof(zval *), 0); zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce); do_inherit_parent_constructor(ce); |