]> granicus.if.org Git - php/commitdiff
Fixed Bug #60369 Crash with static property in trait
authorStefan Marr <gron@php.net>
Wed, 23 Nov 2011 21:24:34 +0000 (21:24 +0000)
committerStefan Marr <gron@php.net>
Wed, 23 Nov 2011 21:24:34 +0000 (21:24 +0000)
Zend/tests/traits/bug60369.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/traits/bug60369.phpt b/Zend/tests/traits/bug60369.phpt
new file mode 100644 (file)
index 0000000..bfc1ee3
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #60369 (Crash with static property in trait)
+--FILE--
+<?php
+
+trait PropertiesTrait {
+   static $same = true;
+}
+
+class Properties {
+   use PropertiesTrait;
+   public $same = true;
+}
+
+?>
+--EXPECTF--
+Fatal error: Properties and PropertiesTrait define the same property ($same) in the composition of Properties. However, the definition differs and is considered incompatible. Class was composed in %s on line %d
\ No newline at end of file
index 40d2e93a9752ecfd98bc3b887efccd3d72dadc6c..215edf61d2f309792617b7be93411edc2be723bb 100644 (file)
@@ -4272,10 +4272,11 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
                                        /* this one is inherited, lets look it up in its own class */
                                        zend_hash_quick_find(&coliding_prop->ce->properties_info, prop_name, prop_name_length+1, prop_hash, (void **) &coliding_prop);
                                }
-                               if ((coliding_prop->flags & ZEND_ACC_PPP_MASK) == (property_info->flags & ZEND_ACC_PPP_MASK)) {
+                               if (   (coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))
+                                       == (property_info->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) {
                                        /* flags are identical, now the value needs to be checked */
                                        if (property_info->flags & ZEND_ACC_STATIC) {
-            not_compatible = (FAILURE == compare_function(&compare_result,
+                                               not_compatible = (FAILURE == compare_function(&compare_result,
                                           ce->default_static_members_table[coliding_prop->offset],
                                           ce->traits[i]->default_static_members_table[property_info->offset] TSRMLS_CC))
                               || (Z_LVAL(compare_result) != 0);