Skip to content

Commit e9fc81a

Browse files
committed
JIT: Fix missing type store
Fixes oss-fuzz #45604
1 parent 7051dc3 commit e9fc81a

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4760,9 +4760,16 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
47604760
#else
47614761
res_use_info = MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE;
47624762
#endif
4763+
res_addr = RES_REG_ADDR();
4764+
if (Z_MODE(res_addr) != IS_REG &&
4765+
STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var)) !=
4766+
STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var))) {
4767+
/* type may be not set */
4768+
res_use_info |= MAY_BE_NULL;
4769+
}
47634770
if (!zend_jit_qm_assign(&dasm_state, opline,
47644771
op1_info, op1_addr, op1_def_addr,
4765-
res_use_info, res_info, RES_REG_ADDR())) {
4772+
res_use_info, res_info, res_addr)) {
47664773
goto jit_failure;
47674774
}
47684775
if (opline->op1_type == IS_CV
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
JIT QM_ASSIGN: 003 missing type store
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+
for($cnt2=0;$cnt<6;$cnt++) {
12+
$a &= 15;
13+
$a = "4294967295";
14+
$a *= $a;
15+
for ($i = 0; $i <= .1; $i++) {
16+
for ($i = 0; $i << .1; $i++) {
17+
$a &= $a . $a = "4294967295";
18+
}
19+
}
20+
}
21+
}
22+
foo();
23+
?>
24+
DONE
25+
--EXPECTF--
26+
Warning: Undefined variable $cnt in %sqm_assign_003.php on line 3
27+
28+
Warning: Undefined variable $a in %sqm_assign_003.php on line 4
29+
30+
Warning: Undefined variable $cnt in %sqm_assign_003.php on line 3
31+
DONE

0 commit comments

Comments
 (0)