mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix leak on foreach by ref assign to property
This commit is contained in:
commit
2efee442eb
11
Zend/tests/foreach_by_ref_to_property.phpt
Normal file
11
Zend/tests/foreach_by_ref_to_property.phpt
Normal file
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Foreach by ref assignment to property
|
||||
--FILE--
|
||||
<?php
|
||||
$obj = new stdClass;
|
||||
foreach ([0] as &$obj->prop) {
|
||||
var_dump($obj->prop);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
@ -3213,17 +3213,13 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
|
||||
opline->extended_value &= ~ZEND_FETCH_REF;
|
||||
opline->extended_value |= flags;
|
||||
zend_emit_op_data(&source_node);
|
||||
if (result != NULL) {
|
||||
*result = target_node;
|
||||
}
|
||||
*result = target_node;
|
||||
} else if (opline && opline->opcode == ZEND_FETCH_STATIC_PROP_W) {
|
||||
opline->opcode = ZEND_ASSIGN_STATIC_PROP_REF;
|
||||
opline->extended_value &= ~ZEND_FETCH_REF;
|
||||
opline->extended_value |= flags;
|
||||
zend_emit_op_data(&source_node);
|
||||
if (result != NULL) {
|
||||
*result = target_node;
|
||||
}
|
||||
*result = target_node;
|
||||
} else {
|
||||
opline = zend_emit_op(result, ZEND_ASSIGN_REF, &target_node, &source_node);
|
||||
opline->extended_value = flags;
|
||||
@ -3233,9 +3229,11 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
|
||||
|
||||
static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, znode *value_node) /* {{{ */
|
||||
{
|
||||
znode dummy_node;
|
||||
zend_ast *assign_ast = zend_ast_create(ZEND_AST_ASSIGN_REF, var_ast,
|
||||
zend_ast_create_znode(value_node));
|
||||
zend_compile_expr(NULL, assign_ast);
|
||||
zend_compile_expr(&dummy_node, assign_ast);
|
||||
zend_do_free(&dummy_node);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user