Skip to content

Commit e20f955

Browse files
committed
JIT: Fix register allocation
Fixes oss-fuzz #45487
1 parent 9792f0d commit e20f955

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15982,6 +15982,7 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1598215982
!(op2_info & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)-MAY_BE_LONG))) {
1598315983
regset = ZEND_REGSET_EMPTY;
1598415984
if (opline->op2_type == IS_CONST &&
15985+
opline->op1_type != IS_CONST &&
1598515986
Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) == IS_LONG &&
1598615987
zend_long_is_power_of_two(Z_LVAL_P(RT_CONSTANT(opline, opline->op2))) &&
1598715988
OP1_HAS_RANGE() &&
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Register Alloction 013: Division by zero
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 foo() {
11+
$j++;
12+
$j++ % $j -= $a % $a = $j;
13+
}
14+
foo();
15+
?>
16+
DONE
17+
--EXPECTF--
18+
Warning: Undefined variable $j in %sreg_alloc_013.php on line 3
19+
DONE

0 commit comments

Comments
 (0)