svn: /php/php-src/trunk/Zend/ tests/bug53748.phpt zend_compile.c
| From: | Felipe Pena | Date: | Fri, 28 Jan 2011 21:19:09 +0000 |
| Subject: | svn: /php/php-src/trunk/Zend/ tests/bug53748.phpt zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64447@lists.php.net to get a copy of this message | ||
felipe Fri, 28 Jan 2011 21:19:09 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=307832
Log:
- Fixed bug #53748 (Using traits lead to a segmentation fault)
Bug: http://bugs.php.net/53748 (Open) Using traits lead to a
segmentation fault
Changed paths:
A php/php-src/trunk/Zend/tests/bug53748.phpt
U php/php-src/trunk/Zend/zend_compile.c
Added: php/php-src/trunk/Zend/tests/bug53748.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug53748.phpt (rev 0)
+++ php/php-src/trunk/Zend/tests/bug53748.phpt 2011-01-28 21:19:09 UTC (rev 307832)
@@ -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)
+}
Property changes on: php/php-src/trunk/Zend/tests/bug53748.phpt
___________________________________________________________________
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ native
Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c 2011-01-28 21:08:59 UTC (rev 307831)
+++ php/php-src/trunk/Zend/zend_compile.c 2011-01-28 21:19:09 UTC (rev 307832)
@@ -3963,6 +3963,7 @@
} 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,