Skip to content

Commit ff7110e

Browse files
committed
Add regression tests for bug #79836
Co-authored-by: changochen1@gmail.com
1 parent f407f39 commit ff7110e

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

Zend/tests/bug79836.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #79836 (Segfault in concat_function)
3+
--INI--
4+
opcache.optimization_level = 0x7FFEBFFF & ~0x400
5+
--FILE--
6+
<?php
7+
$counter = 0;
8+
ob_start(function ($buffer) use (&$c, &$counter) {
9+
$c = 0;
10+
++$counter;
11+
}, 1);
12+
$c .= [];
13+
$c .= [];
14+
ob_end_clean();
15+
echo $counter . "\n";
16+
?>
17+
--EXPECT--
18+
3

Zend/tests/bug79836_1.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #79836 (Segfault in concat_function)
3+
--INI--
4+
opcache.optimization_level = 0x7FFEBFFF & ~0x400
5+
--FILE--
6+
<?php
7+
$x = 'non-empty';
8+
ob_start(function () use (&$c) {
9+
$c = 0;
10+
}, 1);
11+
$c = [];
12+
$x = $c . $x;
13+
$x = $c . $x;
14+
ob_end_clean();
15+
echo "Done\n";
16+
?>
17+
--EXPECT--
18+
Done

Zend/tests/bug79836_2.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #79836 (Segfault in concat_function)
3+
--FILE--
4+
<?php
5+
$c = str_repeat("abcd", 10);
6+
7+
ob_start(function () use (&$c) {
8+
$c = 0;
9+
}, 1);
10+
11+
class X {
12+
function __toString() {
13+
echo "a";
14+
return "abc";
15+
}
16+
}
17+
18+
$xxx = new X;
19+
20+
$x = $c . $xxx;
21+
ob_end_clean();
22+
echo $x . "\n";
23+
?>
24+
--EXPECT--
25+
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc

0 commit comments

Comments
 (0)