Skip to content

Commit f720fb1

Browse files
L3o-poldnikic
authored andcommitted
Add unit test for bug #78902
1 parent db9776c commit f720fb1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #78902: Memory leak when using stream_filter_append
3+
--XFAIL--
4+
This bug was introduced in PHP 7.3.11 an is still open
5+
--INI--
6+
memory_limit=512k
7+
--FILE--
8+
<?php
9+
10+
/** create temporary file 2mb file */
11+
$tmp_file_name = tempnam(sys_get_temp_dir(), 'test_');
12+
$fp = fopen($tmp_file_name, 'w+');
13+
$size = 1024 * 1024 * 2; // 2mb
14+
$chunk = 1024;
15+
while ($size > 0) {
16+
fputs($fp, str_pad('', min($chunk,$size)));
17+
$size -= $chunk;
18+
}
19+
fclose($fp);
20+
21+
$fp = fopen($tmp_file_name, 'r');
22+
stream_filter_append($fp, "string.toupper");
23+
while (!feof($fp)) {
24+
fread($fp, 1);
25+
}
26+
fclose($fp);
27+
var_dump(true);
28+
?>
29+
--EXPECT--
30+
bool(true)

0 commit comments

Comments
 (0)