Skip to content

Commit 3b9ba7b

Browse files
committed
Fixed bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
1 parent 6ed242d commit 3b9ba7b

File tree

3 files changed

+69
-6
lines changed

3 files changed

+69
-6
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PHP NEWS
33
?? ??? 2017, PHP 7.1.13
44

55
- Core:
6+
. Fixed bug #75573 (Segmentation fault in 7.1.12 and 7.0.26). (Laruence)
67
. Fixed bug #75384 (PHP seems incompatible with OneDrive files on demand).
78
(Anatol)
89
. Fixed bug #74862 (Unable to clone instance when private __clone defined).

Zend/tests/bug75573.phpt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--TEST--
2+
Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
var $_stdObject;
9+
function initialize($properties = FALSE) {
10+
$this->_stdObject = $properties ? (object) $properties : new stdClass();
11+
parent::initialize();
12+
}
13+
function &__get($property)
14+
{
15+
if (isset($this->_stdObject->{$property})) {
16+
$retval =& $this->_stdObject->{$property};
17+
return $retval;
18+
} else {
19+
return NULL;
20+
}
21+
}
22+
function &__set($property, $value)
23+
{
24+
return $this->_stdObject->{$property} = $value;
25+
}
26+
function __isset($property_name)
27+
{
28+
return isset($this->_stdObject->{$property_name});
29+
}
30+
}
31+
32+
class B extends A
33+
{
34+
function initialize($properties = array())
35+
{
36+
parent::initialize($properties);
37+
}
38+
function &__get($property)
39+
{
40+
if (isset($this->settings) && isset($this->settings[$property])) {
41+
$retval =& $this->settings[$property];
42+
return $retval;
43+
} else {
44+
return parent::__get($property);
45+
}
46+
}
47+
}
48+
49+
$b = new B();
50+
$b->settings = [ "foo" => "bar", "name" => "abc" ];
51+
var_dump($b->name);
52+
var_dump($b->settings);
53+
?>
54+
--EXPECTF--
55+
Warning: Creating default object from empty value in %sbug75573.php on line %d
56+
57+
Notice: Only variable references should be returned by reference in %sbug75573.php on line %d
58+
string(3) "abc"
59+
array(2) {
60+
["foo"]=>
61+
string(3) "bar"
62+
["name"]=>
63+
string(3) "abc"
64+
}

Zend/zend_object_handlers.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,13 +668,11 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_
668668
}
669669
zval_ptr_dtor(&tmp_object);
670670
goto exit;
671-
} else {
671+
} else if (Z_STRVAL_P(member)[0] == '\0' && Z_STRLEN_P(member) != 0) {
672672
zval_ptr_dtor(&tmp_object);
673-
if (Z_STRVAL_P(member)[0] == '\0' && Z_STRLEN_P(member) != 0) {
674-
zend_throw_error(NULL, "Cannot access property started with '\\0'");
675-
retval = &EG(uninitialized_zval);
676-
goto exit;
677-
}
673+
zend_throw_error(NULL, "Cannot access property started with '\\0'");
674+
retval = &EG(uninitialized_zval);
675+
goto exit;
678676
}
679677
}
680678

0 commit comments

Comments
 (0)