Skip to content

Commit 39f0950

Browse files
committed
Fixed bug #71336 (Wrong is_ref on properties as exposed via get_object_vars())
1 parent 50be2c8 commit 39f0950

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

NEWS

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2016 PHP 7.0.3
44

5-
- Apache2handler:
6-
. Fix >2G Content-Length headers in apache2handler. (Adam Harvey)
7-
85
- Core:
6+
. Fixed bug #71336 (Wrong is_ref on properties as exposed via
7+
get_object_vars()). (Laruence)
98
. Fixed bug #71248 (Wrong interface is enforced). (Dmitry)
109
. Fixed bug #71300 (Segfault in zend_fetch_string_offset). (Laruence)
1110
. Fixed bug #71221 (Null pointer deref (segfault) in get_defined_vars via
@@ -19,6 +18,9 @@ PHP NEWS
1918
. Fixed bug #71297 (Memory leak with consecutive yield from). (Bob)
2019
. Fixed bug #71314 (var_export(INF) prints INF.0). (Andrea)
2120

21+
- Apache2handler:
22+
. Fix >2G Content-Length headers in apache2handler. (Adam Harvey)
23+
2224
- CURL:
2325
. Fixed bug #71227 (Can't compile php_curl statically). (Anatol)
2426
. Fixed bug #71225 (curl_setopt() fails to set CURLOPT_POSTFIELDS with

Zend/tests/bug71336.phpt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Bug #71336 (Wrong is_ref on properties as exposed via get_object_vars())
3+
--FILE--
4+
<?php
5+
class A
6+
{
7+
protected $bar = array('baz');
8+
9+
function bar()
10+
{
11+
array_pop($this->bar);
12+
$vars = get_object_vars($this);
13+
$this->bar[] = array('buz');
14+
print_r($vars);
15+
}
16+
17+
function foo() {
18+
array_pop($this->bar);
19+
$dummy = &$this->bar;
20+
$vars = get_object_vars($this);
21+
$this->bar[] = array('buz');
22+
print_r($vars);
23+
}
24+
}
25+
26+
(new A())->bar();
27+
(new A())->foo();
28+
?>
29+
--EXPECT--
30+
Array
31+
(
32+
[bar] => Array
33+
(
34+
)
35+
36+
)
37+
Array
38+
(
39+
[bar] => Array
40+
(
41+
[0] => Array
42+
(
43+
[0] => buz
44+
)
45+
46+
)
47+
48+
)

Zend/zend_builtin_functions.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,12 @@ ZEND_FUNCTION(get_object_vars)
11981198
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
11991199
if (key) {
12001200
if (zend_check_property_access(zobj, key) == SUCCESS) {
1201-
/* Not separating references */
1202-
if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
1201+
if (Z_ISREF_P(value) && Z_REFCOUNT_P(value) == 1) {
1202+
value = Z_REFVAL_P(value);
1203+
}
1204+
if (Z_REFCOUNTED_P(value)) {
1205+
Z_ADDREF_P(value);
1206+
}
12031207
if (ZSTR_VAL(key)[0] == 0) {
12041208
const char *prop_name, *class_name;
12051209
size_t prop_len;

0 commit comments

Comments
 (0)