Skip to content

Commit 6ed3b57

Browse files
committed
Fix incorrect constant propagation for VERIFY_RETURN_TYPE
Fixes oss-fuzz #46616
1 parent fbb7393 commit 6ed3b57

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Zend/Optimizer/sccp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,10 @@ static zval *value_from_type_and_range(sccp_ctx *ctx, int var_num, zval *tmp) {
17211721
}
17221722

17231723
if (!(info->type & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_NULL))) {
1724+
if (ssa->vars[var_num].definition >= 0
1725+
&& ctx->scdf.op_array->opcodes[ssa->vars[var_num].definition].opcode == ZEND_VERIFY_RETURN_TYPE) {
1726+
return NULL;
1727+
}
17241728
ZVAL_NULL(tmp);
17251729
return tmp;
17261730
}

ext/opcache/tests/opt/sccp_039.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
SCCP 039: Incorrect constant propagation for VERIFY_RETURN_TYPE
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--FILE--
8+
<?php
9+
function foo(): null {
10+
return Y;
11+
}
12+
?>
13+
DONE
14+
--EXPECT--
15+
DONE

0 commit comments

Comments
 (0)