Skip to content

Commit f9518c3

Browse files
committed
Fixed incorrect narrowing to double
Fixes oss-fuzz #41223
1 parent 3c53a9f commit f9518c3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3918,7 +3918,7 @@ static zend_bool can_convert_to_double(
39183918
for (phi = var->phi_use_chain; phi; phi = zend_ssa_next_use_phi(ssa, var_num, phi)) {
39193919
/* Check that narrowing can actually be useful */
39203920
type = ssa->var_info[phi->ssa_var].type;
3921-
if ((type & MAY_BE_ANY) & ~(MAY_BE_LONG|MAY_BE_DOUBLE)) {
3921+
if (type & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) {
39223922
return 0;
39233923
}
39243924

ext/opcache/tests/jit/assign_047.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
JIT ASSIGN: incorrect narrowing to double
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
function test(){
12+
$x = (object)['x'=>0];
13+
for($i=0;$i<10;$i++){
14+
+$a;
15+
$a=$x->x;
16+
$a=7;
17+
}
18+
}
19+
test()
20+
?>
21+
DONE
22+
--EXPECTF--
23+
Warning: Undefined variable $a in %sassign_047.php on line 5
24+
DONE
25+

0 commit comments

Comments
 (0)