Skip to content

Commit f86a963

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Also make sure binary op operands can't be undef
2 parents b9a6ec2 + 8c3d33a commit f86a963

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,6 +2649,9 @@ static bool zend_jit_next_is_send_result(const zend_op *opline)
26492649

26502650
static bool zend_jit_supported_binary_op(zend_uchar op, uint32_t op1_info, uint32_t op2_info)
26512651
{
2652+
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
2653+
return false;
2654+
}
26522655
switch (op) {
26532656
case ZEND_POW:
26542657
case ZEND_DIV:
@@ -3091,9 +3094,6 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
30913094
}
30923095
op1_info = OP1_INFO();
30933096
op2_info = OP2_INFO();
3094-
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
3095-
break;
3096-
}
30973097
if (!zend_jit_supported_binary_op(
30983098
opline->extended_value, op1_info, op2_info)) {
30993099
break;

ext/opcache/jit/zend_jit_trace.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4323,9 +4323,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
43234323
CHECK_OP1_TRACE_TYPE();
43244324
op2_info = OP2_INFO();
43254325
CHECK_OP2_TRACE_TYPE();
4326-
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
4327-
break;
4328-
}
43294326
if (!zend_jit_supported_binary_op(
43304327
opline->extended_value, op1_info, op2_info)) {
43314328
break;
@@ -4350,11 +4347,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
43504347
}
43514348
goto done;
43524349
case ZEND_ASSIGN_DIM_OP:
4353-
if (opline->extended_value == ZEND_POW
4354-
|| opline->extended_value == ZEND_DIV) {
4355-
// TODO: check for division by zero ???
4356-
break;
4357-
}
43584350
if (opline->result_type != IS_UNUSED) {
43594351
break;
43604352
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
--EXTENSIONS--
14+
opcache
15+
--EXPECTF--
16+
Warning: Undefined variable $b in %s on line %d

0 commit comments

Comments
 (0)