Skip to content

Commit 3e78964

Browse files
committed
Fix type inference
Use MAY_BE_NULL result (insted of empty) for ASSIGN_DIM with invalid arguments This fixes oss-fuzz #46840
1 parent 8286de2 commit 3e78964

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,9 @@ 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;
2644+
}
26422645
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
26432646
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
26442647
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Type inference 005: Use MAY_BE_NULL result (insted of empty) for ASSIGN_DIM with invalid arguments
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function foo() {
10+
$a = $r[] = $r = [] & $y;
11+
+list(&$y) = $a;
12+
}
13+
?>
14+
DONE
15+
--EXPECT--
16+
DONE

0 commit comments

Comments
 (0)