Skip to content

Commit 0537560

Browse files
committed
Fix type inference
This fixes oss-fuzz #47422
1 parent 5a39f4c commit 0537560

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,8 +2639,8 @@ static zend_always_inline int _zend_update_type_info(
26392639
tmp |= MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING;
26402640
}
26412641
}
2642-
if (!tmp) {
2643-
tmp = MAY_BE_NULL;
2642+
if (t1 & (MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_RESOURCE)) {
2643+
tmp |= MAY_BE_NULL;
26442644
}
26452645
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
26462646
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Type inference 008: ASSIGN_DIM with invalid op1
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function y() {
10+
$j = 0;
11+
for(;;) {
12+
$cs = $a + $a;
13+
$a = [] ?? $cs[] = $j;
14+
}
15+
}
16+
?>
17+
DONE
18+
--EXPECT--
19+
DONE

0 commit comments

Comments
 (0)