]> granicus.if.org Git - php/commitdiff
Add unit test for bug #78902
authorLéopold Jacquot <leopold.jacquot@infomaniak.com>
Wed, 4 Dec 2019 14:14:50 +0000 (15:14 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 23 Jan 2020 13:53:28 +0000 (14:53 +0100)
ext/standard/tests/streams/bug78902.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/streams/bug78902.phpt b/ext/standard/tests/streams/bug78902.phpt
new file mode 100644 (file)
index 0000000..43b271f
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Bug #78902: Memory leak when using stream_filter_append
+--XFAIL--
+This bug was introduced in PHP 7.3.11 an is still open
+--INI--
+memory_limit=512k
+--FILE--
+<?php
+
+/** create temporary file 2mb file */
+$tmp_file_name = tempnam(sys_get_temp_dir(), 'test_');
+$fp = fopen($tmp_file_name, 'w+');
+$size = 1024 * 1024 * 2; // 2mb
+$chunk = 1024;
+while ($size > 0) {
+    fputs($fp, str_pad('', min($chunk,$size)));
+    $size -= $chunk;
+}
+fclose($fp);
+
+$fp = fopen($tmp_file_name, 'r');
+stream_filter_append($fp, "string.toupper");
+while (!feof($fp)) {
+    fread($fp, 1);
+}
+fclose($fp);
+var_dump(true);
+?>
+--EXPECT--
+bool(true)