xref: /PHP-8.4/ext/bz2/tests/bug81092.phpt (revision a1738d8b)
1--TEST--
2Bug #81092 (fflush before stream_filter_remove corrupts stream)
3--EXTENSIONS--
4bz2
5--FILE--
6<?php
7$stream = fopen(__DIR__ . "/81092.bz2", 'wb+');
8$filter = stream_filter_append($stream, 'bzip2.compress', STREAM_FILTER_WRITE, ['blocks' => 9, 'work' => 0]);
9fwrite($stream, random_bytes(8192));
10fflush($stream);
11stream_filter_remove($filter);
12
13var_dump(strlen(bzdecompress(file_get_contents(__DIR__ . "/81092.bz2"))));
14?>
15--CLEAN--
16<?php
17@unlink(__DIR__ . "/81092.bz2");
18?>
19--EXPECT--
20int(8192)
21