mirror of
https://github.com/php/php-src.git
synced 2024-12-27 02:39:39 +08:00
Merge branch 'PHP-7.0'
This commit is contained in:
commit
fea822fe1b
25
Zend/tests/modify_isref_value_return.phpt
Normal file
25
Zend/tests/modify_isref_value_return.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Indirect modification of isref by-value return value not possible
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class A {
|
||||
public $b;
|
||||
}
|
||||
|
||||
$arr = [];
|
||||
|
||||
$a = new A;
|
||||
$a->b =& $arr;
|
||||
|
||||
(new ReflectionProperty('A', 'b'))->getValue($a)[] = 42;
|
||||
|
||||
var_dump($a);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
object(A)#1 (1) {
|
||||
["b"]=>
|
||||
&array(0) {
|
||||
}
|
||||
}
|
@ -7436,11 +7436,12 @@ ZEND_VM_HANDLER(156, ZEND_SEPARATE, VAR, UNUSED)
|
||||
if (UNEXPECTED(Z_ISREF_P(var_ptr))) {
|
||||
if (UNEXPECTED(Z_REFCOUNT_P(var_ptr) == 1)) {
|
||||
ZVAL_UNREF(var_ptr);
|
||||
} else if (!(Z_VAR_FLAGS_P(var_ptr) & IS_VAR_RET_REF)) {
|
||||
Z_DELREF_P(var_ptr);
|
||||
ZVAL_COPY(var_ptr, Z_REFVAL_P(var_ptr));
|
||||
}
|
||||
} else if (Z_COPYABLE_P(var_ptr) && Z_REFCOUNT_P(var_ptr) > 1) {
|
||||
Z_DELREF_P(var_ptr);
|
||||
ZVAL_DUP(EX_VAR(opline->op1.var), var_ptr);
|
||||
}
|
||||
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
|
@ -21393,11 +21393,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEPARATE_SPEC_VAR_UNUSED_HANDL
|
||||
if (UNEXPECTED(Z_ISREF_P(var_ptr))) {
|
||||
if (UNEXPECTED(Z_REFCOUNT_P(var_ptr) == 1)) {
|
||||
ZVAL_UNREF(var_ptr);
|
||||
} else if (!(Z_VAR_FLAGS_P(var_ptr) & IS_VAR_RET_REF)) {
|
||||
Z_DELREF_P(var_ptr);
|
||||
ZVAL_COPY(var_ptr, Z_REFVAL_P(var_ptr));
|
||||
}
|
||||
} else if (Z_COPYABLE_P(var_ptr) && Z_REFCOUNT_P(var_ptr) > 1) {
|
||||
Z_DELREF_P(var_ptr);
|
||||
ZVAL_DUP(EX_VAR(opline->op1.var), var_ptr);
|
||||
}
|
||||
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user