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