Skip to content

Commit 2c8d2eb

Browse files
committed
Don't emit ZEND_DEREF in stmt context
1 parent 2be9462 commit 2c8d2eb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Zend/zend_compile.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3611,19 +3611,27 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast, uint32_t type)
36113611
opline->extended_value &= ~ZEND_FETCH_REF;
36123612
opline->extended_value |= flags;
36133613
zend_emit_op_data(&source_node);
3614-
*result = target_node;
3614+
if (result) {
3615+
*result = target_node;
3616+
} else {
3617+
SET_UNUSED(opline->result);
3618+
}
36153619
} else if (opline && opline->opcode == ZEND_FETCH_STATIC_PROP_W) {
36163620
opline->opcode = ZEND_ASSIGN_STATIC_PROP_REF;
36173621
opline->extended_value &= ~ZEND_FETCH_REF;
36183622
opline->extended_value |= flags;
36193623
zend_emit_op_data(&source_node);
3620-
*result = target_node;
3624+
if (result) {
3625+
*result = target_node;
3626+
} else {
3627+
SET_UNUSED(opline->result);
3628+
}
36213629
} else {
36223630
opline = zend_emit_op(result, ZEND_ASSIGN_REF, &target_node, &source_node);
36233631
opline->extended_value = flags;
36243632
}
36253633

3626-
if (type == BP_VAR_R || type == BP_VAR_IS) {
3634+
if (result && (type == BP_VAR_R || type == BP_VAR_IS)) {
36273635
znode tmp_result = *result;
36283636
zend_emit_op_tmp(result, ZEND_DEREF, &tmp_result, NULL);
36293637
}
@@ -11934,6 +11942,9 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */
1193411942
case ZEND_AST_CAST_VOID:
1193511943
zend_compile_void_cast(NULL, ast);
1193611944
break;
11945+
case ZEND_AST_ASSIGN_REF:
11946+
zend_compile_assign_ref(NULL, ast, BP_VAR_R);
11947+
return;
1193711948
default:
1193811949
{
1193911950
znode result;

0 commit comments

Comments
 (0)