xref: /PHP-8.2/tests/basic/bug80384.phpt (revision 70dfbe00)
1--TEST--
2Bug #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');
8for ($i=0; $i<1024; $i++) {
9    fwrite($fp, str_repeat('ABCDEFGH', 1024));
10}
11fclose($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();
18fread($fp, 8 * 1024 * 1024);
19$mem_final = memory_get_usage();
20fclose($fp);
21var_dump($mem_final - $mem_start < 32768);
22?>
23--CLEAN--
24<?php
25unlink(__DIR__ . "/bug80384.tmp");
26?>
27--EXPECT--
28bool(true)
29