Skip to content

Commit d46b102

Browse files
committed
Don't jit FE_RESET_R with undef operand
The implementation currently assumes that the operand is always an array, but this did not account for a possibly undef operand.
1 parent e250ce6 commit d46b102

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3282,7 +3282,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32823282
goto done;
32833283
case ZEND_FE_RESET_R:
32843284
op1_info = OP1_INFO();
3285-
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_ARRAY) {
3285+
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) != MAY_BE_ARRAY) {
32863286
break;
32873287
}
32883288
if (!zend_jit_fe_reset(&dasm_state, opline, op1_info)) {

ext/opcache/jit/zend_jit_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5527,7 +5527,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
55275527
case ZEND_FE_RESET_R:
55285528
op1_info = OP1_INFO();
55295529
CHECK_OP1_TRACE_TYPE();
5530-
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_ARRAY) {
5530+
if ((op1_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) != MAY_BE_ARRAY) {
55315531
break;
55325532
}
55335533
if (!zend_jit_fe_reset(&dasm_state, opline, op1_info)) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
FE_RESET with potentially undef operand
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function test($c) {
11+
if ($c) {
12+
$a[] = null;
13+
}
14+
foreach ($a as $k) {}
15+
}
16+
test(false);
17+
?>
18+
--EXPECTF--
19+
Warning: Undefined variable $a in %s on line %d
20+
21+
Warning: foreach() argument must be of type array|object, null given in %s on line %d

0 commit comments

Comments
 (0)