1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fixed code generation for MOD

Fixes oss-fuzz #63570
This commit is contained in:
Dmitry Stogov
2023-10-25 13:14:34 +03:00
parent c2b704b63e
commit 9f5a4c3799
2 changed files with 24 additions and 3 deletions

View File

@@ -5413,7 +5413,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
jit_SET_EX_OPLINE(jit, opline);
ir_GUARD(IR_FALSE, jit_STUB_ADDR(jit, jit_stub_negative_shift));
if (Z_MODE(res_addr) == IS_REG) {
zend_jit_def_reg(jit, res_addr, ir_CONST_LONG(0)); // dead code
ref = ir_CONST_LONG(0); // dead code
}
}
} else {
@@ -5462,7 +5462,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
jit_SET_EX_OPLINE(jit, opline);
ir_GUARD(IR_FALSE, jit_STUB_ADDR(jit, jit_stub_negative_shift));
if (Z_MODE(res_addr) == IS_REG) {
zend_jit_def_reg(jit, res_addr, ir_CONST_LONG(0)); // dead code
ref = ir_CONST_LONG(0); // dead code
}
}
} else {
@@ -5503,7 +5503,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
jit_SET_EX_OPLINE(jit, opline);
ir_GUARD(IR_FALSE, jit_STUB_ADDR(jit, jit_stub_mod_by_zero));
if (Z_MODE(res_addr) == IS_REG) {
zend_jit_def_reg(jit, res_addr, ir_CONST_LONG(0)); // dead code
ref = ir_CONST_LONG(0); // dead code
}
} else if (zend_long_is_power_of_two(op2_lval) && op1_range && op1_range->min >= 0) {
ref = ir_AND_L(jit_Z_LVAL(jit, op1_addr), ir_CONST_LONG(op2_lval - 1));

View File

@@ -0,0 +1,21 @@
--TEST--
JIT MOD: 008
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--FILE--
<?php
function foo() {
foo(1 / 0 % 0);
};
@foo();
?>
--EXPECTF--
Fatal error: Uncaught DivisionByZeroError: Division by zero in %smod_008.php:3
Stack trace:
#0 %smod_008.php(5): foo()
#1 {main}
thrown in %smod_008.php on line 3