Skip to content

Commit 3f1e1b9

Browse files
committed
Fix type inference
This fixes oss-fuzz #47049
1 parent 23a2030 commit 3f1e1b9

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,10 +3219,11 @@ static zend_always_inline int _zend_update_type_info(
32193219
tmp |= t1 & (MAY_BE_RC1|MAY_BE_RCN);
32203220
}
32213221
}
3222-
if (opline->opcode == ZEND_FETCH_DIM_RW
3222+
if ((key_type & (MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING))
3223+
&& (opline->opcode == ZEND_FETCH_DIM_RW
32233224
|| opline->opcode == ZEND_FETCH_DIM_W
32243225
|| opline->opcode == ZEND_FETCH_DIM_FUNC_ARG
3225-
|| opline->opcode == ZEND_FETCH_LIST_W) {
3226+
|| opline->opcode == ZEND_FETCH_LIST_W)) {
32263227
j = ssa_vars[ssa_op->result_def].use_chain;
32273228
if (j < 0) {
32283229
/* no uses */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Type inference 006: FETCH_DIM_W with invalid key type
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function y() {
10+
$obj=new y;
11+
u($y[$obj]);
12+
}
13+
?>
14+
DONE
15+
--EXPECT--
16+
DONE

0 commit comments

Comments
 (0)