Skip to content

Commit 7aa9ef7

Browse files
committed
Fixed incorrect type assumption
Fixes oss-fuzz #63809
1 parent bc47e2d commit 7aa9ef7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6446,8 +6446,14 @@ static int zend_jit_assign(zend_jit_ctx *jit,
64466446
/* We have to update type of CV because it may be captured by exception backtrace or released on RETURN */
64476447
if ((op1_def_info & MAY_BE_ANY) == MAY_BE_LONG) {
64486448
jit_set_Z_TYPE_INFO(jit, op1_use_addr, IS_LONG);
6449+
if (JIT_G(current_frame)) {
6450+
SET_STACK_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(Z_OFFSET(op1_use_addr)), IS_LONG, 1);
6451+
}
64496452
} else if ((op1_def_info & MAY_BE_ANY) == MAY_BE_DOUBLE) {
64506453
jit_set_Z_TYPE_INFO(jit, op1_use_addr, IS_DOUBLE);
6454+
if (JIT_G(current_frame)) {
6455+
SET_STACK_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(Z_OFFSET(op1_use_addr)), IS_DOUBLE, 1);
6456+
}
64516457
} else {
64526458
ZEND_UNREACHABLE();
64536459
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Register Alloction 022: Incorrect type assumption
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 test() {
11+
$a = $b = $x = 0; $c = null;
12+
for ($i = 0; $i < 20; $i++) {
13+
$x .= $b;
14+
$x = $a ? $b : $c;
15+
$a &= $x != $a ? $b : $c;
16+
$x = $a ? $b : $c;
17+
$a &= $x != $a ? $b : $c;
18+
$x != $a ?: $c;
19+
$a--;
20+
}
21+
}
22+
test();
23+
?>
24+
DONE
25+
--EXPECT--
26+
DONE

0 commit comments

Comments
 (0)