Skip to content

Commit 3f4bc94

Browse files
committed
Mitigation for bug #81096
This issue is properly fixed by GH-7121 on master. For older branches, disable the use of range information in SCCP, to reduce impact of potentially incorrect ranges.
1 parent a1738d8 commit 3f4bc94

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ext/opcache/Optimizer/sccp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,13 +2193,16 @@ static zval *value_from_type_and_range(sccp_ctx *ctx, int var_num, zval *tmp) {
21932193
return tmp;
21942194
}
21952195

2196+
#if 0
2197+
/* Disabled due to bug #81096. */
21962198
if (!(info->type & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG))
21972199
&& info->has_range
21982200
&& !info->range.overflow && !info->range.underflow
21992201
&& info->range.min == info->range.max) {
22002202
ZVAL_LONG(tmp, info->range.min);
22012203
return tmp;
22022204
}
2205+
#endif
22032206

22042207
return NULL;
22052208
}

ext/opcache/tests/ref_range_1.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Range info for references (1)
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
escape_x($x);
8+
$x = 0;
9+
modify_x();
10+
return (int) $x;
11+
}
12+
13+
function escape_x(&$x) {
14+
$GLOBALS['x'] =& $x;
15+
}
16+
17+
function modify_x() {
18+
$GLOBALS['x']++;
19+
}
20+
21+
var_dump(test());
22+
23+
?>
24+
--EXPECT--
25+
int(1)

0 commit comments

Comments
 (0)