Skip to content

Commit

Permalink
Merge branch 'PHP-7.1' into PHP-7.2
Browse files Browse the repository at this point in the history
* PHP-7.1:
  Fixed bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
  • Loading branch information
laruence committed Nov 29, 2017
2 parents a1845b7 + 3b9ba7b commit bedf609
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
64 changes: 64 additions & 0 deletions Zend/tests/bug75573.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
--TEST--
Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
--FILE--
<?php

class A
{
var $_stdObject;
function initialize($properties = FALSE) {
$this->_stdObject = $properties ? (object) $properties : new stdClass();
parent::initialize();
}
function &__get($property)
{
if (isset($this->_stdObject->{$property})) {
$retval =& $this->_stdObject->{$property};
return $retval;
} else {
return NULL;
}
}
function &__set($property, $value)
{
return $this->_stdObject->{$property} = $value;
}
function __isset($property_name)
{
return isset($this->_stdObject->{$property_name});
}
}

class B extends A
{
function initialize($properties = array())
{
parent::initialize($properties);
}
function &__get($property)
{
if (isset($this->settings) && isset($this->settings[$property])) {
$retval =& $this->settings[$property];
return $retval;
} else {
return parent::__get($property);
}
}
}

$b = new B();
$b->settings = [ "foo" => "bar", "name" => "abc" ];
var_dump($b->name);
var_dump($b->settings);
?>
--EXPECTF--
Warning: Creating default object from empty value in %sbug75573.php on line %d

Notice: Only variable references should be returned by reference in %sbug75573.php on line %d
string(3) "abc"
array(2) {
["foo"]=>
string(3) "bar"
["name"]=>
string(3) "abc"
}
10 changes: 4 additions & 6 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,11 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
}
zval_ptr_dtor(&tmp_object);
goto exit;
} else {
} else if (Z_STRVAL_P(member)[0] == '\0' && Z_STRLEN_P(member) != 0) {
zval_ptr_dtor(&tmp_object);
if (Z_STRVAL_P(member)[0] == '\0' && Z_STRLEN_P(member) != 0) {
zend_throw_error(NULL, "Cannot access property started with '\\0'");
retval = &EG(uninitialized_zval);
goto exit;
}
zend_throw_error(NULL, "Cannot access property started with '\\0'");
retval = &EG(uninitialized_zval);
goto exit;
}
}

Expand Down

0 comments on commit bedf609

Please sign in to comment.