Skip to content

Commit

Permalink
- Fixed bug #53748 (Using traits lead to a segmentation fault)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 28, 2011
1 parent 0e7c00f commit f6a3cd6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Zend/tests/bug53748.phpt
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f6a3cd6

Please sign in to comment.