com php-src: Fix #75607 - Check if existing static trait property is a ref before comparing: Zend/tests/traits/bug75607.phpt
Zend/tests/traits/bug75607a.phpt Zend/zend_inheritance.c
| From: | Nikita Popov | Date: | Sat, 16 Dec 2017 16:07:12 +0000 |
| Subject: | com php-src: Fix #75607 - Check if existing static trait property is a ref before comparing: Zend/tests/traits/bug75607.phpt Zend/tests/traits/bug75607a.phpt Zend/zend_inheritance.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100612@lists.php.net to get a copy of this message | ||
Commit: 83964e0468e7f4ae39cd1435f3b53f62e174ac21
Author: Pedro Magalhães <mail@pmmaga.net> Fri, 1 Dec 2017 16:08:11 +0000
Committer: Nikita Popov <nikita.ppv@gmail.com> Sat, 16 Dec 2017 17:07:12 +0100
Parents: a20c9bd3fec9b1df83193ae0db18cb04064461e3
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=83964e0468e7f4ae39cd1435f3b53f62e174ac21
Log:
Fix #75607 - Check if existing static trait property is a ref before comparing
Bugs:
https://bugs.php.net/75607
Changed paths:
A Zend/tests/traits/bug75607.phpt
A Zend/tests/traits/bug75607a.phpt
M Zend/zend_inheritance.c
Diff:
diff --git a/Zend/tests/traits/bug75607.phpt b/Zend/tests/traits/bug75607.phpt
new file mode 100644
index 0000000..a3a1042
--- /dev/null
+++ b/Zend/tests/traits/bug75607.phpt
@@ -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
index 0000000..9f5f035
--- /dev/null
+++ b/Zend/tests/traits/bug75607a.phpt
@@ -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)
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 7689a7c..383df1a 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -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;