]> granicus.if.org Git - php/commitdiff
Fix #75607 - Check if existing static trait property is a ref before comparing
authorPedro Magalhães <mail@pmmaga.net>
Fri, 1 Dec 2017 16:08:11 +0000 (16:08 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 16 Dec 2017 16:07:12 +0000 (17:07 +0100)
Zend/tests/traits/bug75607.phpt [new file with mode: 0644]
Zend/tests/traits/bug75607a.phpt [new file with mode: 0644]
Zend/zend_inheritance.c

diff --git a/Zend/tests/traits/bug75607.phpt b/Zend/tests/traits/bug75607.phpt
new file mode 100644 (file)
index 0000000..a3a1042
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Bug #75607 (Comparision of initial static properties failing)
+--FILE--
+<?php
+
+trait T1
+{
+       public static $prop1 = 1;
+}
+
+class Base
+{
+       public static $prop1 = 1;
+}
+
+class Child extends base
+{
+       use T1;
+}
+
+echo "DONE";
+
+?>
+--EXPECT--
+DONE
diff --git a/Zend/tests/traits/bug75607a.phpt b/Zend/tests/traits/bug75607a.phpt
new file mode 100644 (file)
index 0000000..9f5f035
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+Bug #75607 (Comparision of initial static properties failing)
+--FILE--
+<?php
+
+trait T1
+{
+       public static $prop1 = 1;
+}
+
+trait T2
+{
+       public static $prop1 = 1;
+}
+
+class Base
+{
+       use T1;
+}
+
+class Child extends base
+{
+       
+}
+
+class Grand extends Child
+{
+       use T2;
+}
+
+$c = new Grand();
+var_dump($c::$prop1);
+
+?>
+--EXPECT--
+int(1)
index 7689a7c963dabf5cb3b0122f1b9909339ae60324..383df1a0f9d8549b713c9b98e648ec5e214cf29b 100644 (file)
@@ -1568,13 +1568,17 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */
                                        if ((coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))
                                                == (flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) {
                                                /* flags are identical, now the value needs to be checked */
+                                               zval *op1, *op2;
                                                if (flags & ZEND_ACC_STATIC) {
-                                                       not_compatible = fast_is_not_identical_function(&ce->default_static_members_table[coliding_prop->offset],
-                                                                                         &ce->traits[i]->default_static_members_table[property_info->offset]);
+                                                       op1 = &ce->default_static_members_table[coliding_prop->offset];
+                                                       op2 = &ce->traits[i]->default_static_members_table[property_info->offset];
+                                                       ZVAL_DEREF(op1);
+                                                       ZVAL_DEREF(op2);
                                                } else {
-                                                       not_compatible = fast_is_not_identical_function(&ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)],
-                                                                                         &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
+                                                       op1 = &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)];
+                                                       op2 = &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)];
                                                }
+                                               not_compatible = fast_is_not_identical_function(op1, op2);
                                        } else {
                                                /* the flags are not identical, thus, we assume properties are not compatible */
                                                not_compatible = 1;