summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2011-01-28 21:19:09 +0000
committerFelipe Pena <felipe@php.net>2011-01-28 21:19:09 +0000
commitf6a3cd6f5733345caf34109198d17c4a873ff7ae (patch)
treebad9d255b3f334965cac4711397989cb89b8d985
parent0e7c00f3a64796d3f0a13330f8037e50fb7e2dec (diff)
downloadphp-git-f6a3cd6f5733345caf34109198d17c4a873ff7ae.tar.gz
- Fixed bug #53748 (Using traits lead to a segmentation fault)
-rw-r--r--Zend/tests/bug53748.phpt39
-rw-r--r--Zend/zend_compile.c1
2 files changed, 40 insertions, 0 deletions
diff --git a/Zend/tests/bug53748.phpt b/Zend/tests/bug53748.phpt
new file mode 100644
index 0000000000..2f171fe455
--- /dev/null
+++ b/Zend/tests/bug53748.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Bug #53748 (Using traits lead to a segmentation fault)
+--FILE--
+<?php
+
+trait Singleton {
+ protected static $instances=array();
+ abstract protected function __construct($config);
+ public static function getInstance($config) {
+ if (!isset(self::$instances[$serialize = serialize($config)])) {
+ self::$instances[$serialize] = new self($config);
+ }
+ return self::$instances[$serialize];
+ }
+}
+
+class MyHelloWorld {
+ use Singleton;
+ public function __construct($config)
+ {
+ var_dump( $config);
+ }
+}
+
+
+$o= myHelloWorld::getInstance(1);
+$o= myHelloWorld::getInstance(1);
+$o= myHelloWorld::getInstance(2);
+$o= myHelloWorld::getInstance(array(1=>2));
+$o= myHelloWorld::getInstance(array(1=>2));
+
+?>
+--EXPECTF--
+int(1)
+int(2)
+array(1) {
+ [1]=>
+ int(2)
+}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 7b7c84869e..5f49c152df 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3963,6 +3963,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* {
} else {
prop_value = ce->traits[i]->default_properties_table[property_info->offset];
}
+ Z_ADDREF_P(prop_value);
zend_declare_property_ex(ce, prop_name, prop_name_length,
prop_value, property_info->flags,