Skip to content

Commit bd30eff

Browse files
committedJul 18, 2022
Fix type inference for FETCH_DI_UNSET
Fixes oss-fuzz #48507
1 parent d830a1f commit bd30eff

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
 

‎ext/opcache/Optimizer/zend_inference.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -3298,7 +3298,12 @@ static zend_always_inline int _zend_update_type_info(
32983298
ZEND_ASSERT(j < 0 && "There should only be one use");
32993299
}
33003300
}
3301-
if (((tmp & MAY_BE_ARRAY) && (tmp & MAY_BE_ARRAY_KEY_ANY)) || opline->opcode == ZEND_FETCH_DIM_FUNC_ARG) {
3301+
if (((tmp & MAY_BE_ARRAY) && (tmp & MAY_BE_ARRAY_KEY_ANY))
3302+
|| opline->opcode == ZEND_FETCH_DIM_FUNC_ARG
3303+
|| opline->opcode == ZEND_FETCH_DIM_R
3304+
|| opline->opcode == ZEND_FETCH_DIM_IS
3305+
|| opline->opcode == ZEND_FETCH_DIM_UNSET
3306+
|| opline->opcode == ZEND_FETCH_LIST_R) {
33023307
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
33033308
} else {
33043309
/* invalid key type */
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Type inference 012: FETCH_DIM_UNSET
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function test() {
10+
$closure = function() {return "string";};
11+
unset($x['b'][$closure()]['d']);
12+
$x = $arr;
13+
$arr = ['a' => $closure(), 'b' => [$closure() => []]];
14+
$x = $arr;
15+
unset($x['b'][$closure()]['d']);
16+
$x = $arr;
17+
}
18+
19+
test();
20+
?>
21+
DONE
22+
--EXPECTF--
23+
Warning: Undefined variable $x in %sinference_012.php on line 4
24+
25+
Warning: Undefined variable $arr in %sinference_012.php on line 5
26+
DONE

0 commit comments

Comments
 (0)
Please sign in to comment.