Skip to content

Commit f65d3ed

Browse files
committed
Add test for bug #80384
1 parent 252bc44 commit f65d3ed

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/basic/bug80384.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #80384 large reads cause filters to internally buffer large amounts of memory
3+
--FILE--
4+
<?php
5+
/* First, create a file to read */
6+
$tmp_filename = __DIR__ . "/bug80384.tmp";
7+
$fp = fopen($tmp_filename, 'w');
8+
for ($i=0; $i<1024; $i++) {
9+
fwrite($fp, str_repeat('ABCDEFGH', 1024));
10+
}
11+
fclose($fp);
12+
13+
/* Stream the file through a filter */
14+
$fp = fopen($tmp_filename, 'r');
15+
$filter = stream_filter_append($fp, "string.rot13");
16+
17+
$mem_start = memory_get_usage();
18+
fread($fp, 8 * 1024 * 1024);
19+
$mem_final = memory_get_usage();
20+
fclose($fp);
21+
var_dump($mem_final - $mem_start < 32768);
22+
?>
23+
--CLEAN--
24+
<?php
25+
unlink(__DIR__ . "/bug80384.tmp");
26+
?>
27+
--EXPECT--
28+
bool(true)

0 commit comments

Comments
 (0)