Skip to content

Commit 8c3d33a

Browse files
committed
Also make sure binary op operands can't be undef
Otherwise we will end up passing undef to xyz_function etc, which is not permitted.
1 parent bac054d commit 8c3d33a

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,9 @@ static zend_lifetime_interval** zend_jit_allocate_registers(const zend_op_array
20702070

20712071
static bool zend_jit_supported_binary_op(zend_uchar op, uint32_t op1_info, uint32_t op2_info)
20722072
{
2073+
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
2074+
return false;
2075+
}
20732076
switch (op) {
20742077
case ZEND_POW:
20752078
case ZEND_DIV:
@@ -2522,9 +2525,6 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
25222525
}
25232526
op1_info = OP1_INFO();
25242527
op2_info = OP2_INFO();
2525-
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
2526-
break;
2527-
}
25282528
if (!zend_jit_supported_binary_op(
25292529
opline->extended_value, op1_info, op2_info)) {
25302530
break;

ext/opcache/jit/zend_jit_trace.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,9 +4157,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
41574157
CHECK_OP1_TRACE_TYPE();
41584158
op2_info = OP2_INFO();
41594159
CHECK_OP2_TRACE_TYPE();
4160-
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
4161-
break;
4162-
}
41634160
if (!zend_jit_supported_binary_op(
41644161
opline->extended_value, op1_info, op2_info)) {
41654162
break;
@@ -4184,11 +4181,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
41844181
}
41854182
goto done;
41864183
case ZEND_ASSIGN_DIM_OP:
4187-
if (opline->extended_value == ZEND_POW
4188-
|| opline->extended_value == ZEND_DIV) {
4189-
// TODO: check for division by zero ???
4190-
break;
4191-
}
41924184
if (opline->result_type != IS_UNUSED) {
41934185
break;
41944186
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
JIT ASSIGN_DIM_OP: Undefined variable variation
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+
$a = [];
11+
$a[] &= $b;
12+
?>
13+
--EXPECTF--
14+
Warning: Undefined variable $b in %s on line %d

0 commit comments

Comments
 (0)