Skip to content

Commit 2022f2e

Browse files
committed
Fix nullsafe operator with delayed oplines
Closes GH-6056.
1 parent 70300f6 commit 2022f2e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Zend/zend_compile.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,12 @@ static zend_op *zend_delayed_compile_end(uint32_t offset) /* {{{ */
22242224
for (i = offset; i < count; ++i) {
22252225
opline = get_next_op();
22262226
memcpy(opline, &oplines[i], sizeof(zend_op));
2227+
if (opline->opcode == ZEND_JMP_NULL) {
2228+
uint32_t opnum = get_next_op_number() - 1;
2229+
zend_stack_push(&CG(short_circuiting_opnums), &opnum);
2230+
}
22272231
}
2232+
22282233
CG(delayed_oplines_stack).top = offset;
22292234
return opline;
22302235
}
@@ -2799,7 +2804,11 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
27992804
opline = zend_delayed_compile_var(&obj_node, obj_ast, type, 0);
28002805
zend_separate_if_call_and_write(&obj_node, obj_ast, type);
28012806
if (nullsafe) {
2802-
zend_emit_jmp_null(&obj_node);
2807+
/* We will push to the short_cirtcuiting_opnums stack in zend_delayed_compile_end(). */
2808+
opline = zend_delayed_emit_op(NULL, ZEND_JMP_NULL, &obj_node, NULL);
2809+
if (opline->op1_type == IS_CONST) {
2810+
Z_TRY_ADDREF_P(CT_CONSTANT(opline->op1));
2811+
}
28032812
}
28042813
}
28052814

0 commit comments

Comments
 (0)