Skip to content

Commit

Permalink
Fix typr inference
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #45020
  • Loading branch information
dstogov committed Feb 28, 2022
1 parent f67986a commit aced867
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions Zend/Optimizer/zend_inference.c
Expand Up @@ -2661,6 +2661,7 @@ static zend_always_inline int _zend_update_type_info(
case ZEND_ASSIGN_DIM:
if (opline->op1_type == IS_CV) {
tmp = assign_dim_result_type(t1, t2, OP1_DATA_INFO(), opline->op2_type);
tmp |= ssa->var_info[ssa_op->op1_def].type & (MAY_BE_ARRAY_PACKED|MAY_BE_ARRAY_NUMERIC_HASH|MAY_BE_ARRAY_STRING_HASH);
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def);
}
Expand Down
26 changes: 26 additions & 0 deletions ext/opcache/tests/jit/assign_dim_013.phpt
@@ -0,0 +1,26 @@
--TEST--
JIT ASSIGN_DIM: 013
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
function test() {
for(;;) {
$arr[] = $obj = new stdClass;
$obj->y = set_error_handler(function(){});
foreach($obj as $y) {
}
$arr = ['' => y];
}
}
test();
?>
--EXPECTF--
Fatal error: Uncaught Error: Undefined constant "y" in %sassign_dim_013.php:8
Stack trace:
#0 %sassign_dim_013.php(11): test()
#1 {main}
thrown in %sassign_dim_013.php on line 8

0 comments on commit aced867

Please sign in to comment.