Fixed incorrect narrowing to double

Fixes oss-fuzz #41223
This commit is contained in:
Dmitry Stogov 2021-11-25 15:14:04 +03:00
parent 3c53a9fd73
commit f9518c3850
2 changed files with 26 additions and 1 deletions

View File

@ -3918,7 +3918,7 @@ static zend_bool can_convert_to_double(
for (phi = var->phi_use_chain; phi; phi = zend_ssa_next_use_phi(ssa, var_num, phi)) {
/* Check that narrowing can actually be useful */
type = ssa->var_info[phi->ssa_var].type;
if ((type & MAY_BE_ANY) & ~(MAY_BE_LONG|MAY_BE_DOUBLE)) {
if (type & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) {
return 0;
}

View File

@ -0,0 +1,25 @@
--TEST--
JIT ASSIGN: incorrect narrowing to double
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--FILE--
<?php
function test(){
$x = (object)['x'=>0];
for($i=0;$i<10;$i++){
+$a;
$a=$x->x;
$a=7;
}
}
test()
?>
DONE
--EXPECTF--
Warning: Undefined variable $a in %sassign_047.php on line 5
DONE