Skip to content

Commit fa75bd0

Browse files
committed
Fix incorrect constant propagation for VERIFY_RETURN_TYPE
This fixes oss-fuzz #48104
1 parent 3d4a55f commit fa75bd0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Zend/Optimizer/sccp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,18 +1721,26 @@ 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
1724+
if (ssa->vars[var_num].definition >= 0
17251725
&& ctx->scdf.op_array->opcodes[ssa->vars[var_num].definition].opcode == ZEND_VERIFY_RETURN_TYPE) {
17261726
return NULL;
17271727
}
17281728
ZVAL_NULL(tmp);
17291729
return tmp;
17301730
}
17311731
if (!(info->type & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_FALSE))) {
1732+
if (ssa->vars[var_num].definition >= 0
1733+
&& ctx->scdf.op_array->opcodes[ssa->vars[var_num].definition].opcode == ZEND_VERIFY_RETURN_TYPE) {
1734+
return NULL;
1735+
}
17321736
ZVAL_FALSE(tmp);
17331737
return tmp;
17341738
}
17351739
if (!(info->type & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_TRUE))) {
1740+
if (ssa->vars[var_num].definition >= 0
1741+
&& ctx->scdf.op_array->opcodes[ssa->vars[var_num].definition].opcode == ZEND_VERIFY_RETURN_TYPE) {
1742+
return NULL;
1743+
}
17361744
ZVAL_TRUE(tmp);
17371745
return tmp;
17381746
}

ext/opcache/tests/opt/sccp_041.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
SCCP 041: 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():false {
10+
return y;
11+
}
12+
?>
13+
DONE
14+
--EXPECT--
15+
DONE

0 commit comments

Comments
 (0)