1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 23:48:14 +02:00

Merge branch 'PHP-7.0'

* PHP-7.0:
  Fixed bug #71336 (Wrong is_ref on properties as exposed via get_object_vars())
This commit is contained in:
Xinchen Hui
2016-01-13 17:38:36 +08:00
2 changed files with 54 additions and 2 deletions
+48
View File
@@ -0,0 +1,48 @@
--TEST--
Bug #71336 (Wrong is_ref on properties as exposed via get_object_vars())
--FILE--
<?php
class A
{
protected $bar = array('baz');
function bar()
{
array_pop($this->bar);
$vars = get_object_vars($this);
$this->bar[] = array('buz');
print_r($vars);
}
function foo() {
array_pop($this->bar);
$dummy = &$this->bar;
$vars = get_object_vars($this);
$this->bar[] = array('buz');
print_r($vars);
}
}
(new A())->bar();
(new A())->foo();
?>
--EXPECT--
Array
(
[bar] => Array
(
)
)
Array
(
[bar] => Array
(
[0] => Array
(
[0] => buz
)
)
)
+6 -2
View File
@@ -1198,8 +1198,12 @@ ZEND_FUNCTION(get_object_vars)
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
if (key) {
if (zend_check_property_access(zobj, key) == SUCCESS) {
/* Not separating references */
if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
if (Z_ISREF_P(value) && Z_REFCOUNT_P(value) == 1) {
value = Z_REFVAL_P(value);
}
if (Z_REFCOUNTED_P(value)) {
Z_ADDREF_P(value);
}
if (ZSTR_VAL(key)[0] == 0) {
const char *prop_name, *class_name;
size_t prop_len;