xref: /PHP-8.2/ext/zlib/tests/bug74240.phpt (revision 74859783)
1--TEST--
2Bug #74240 (deflate_add can allocate too much memory)
3--EXTENSIONS--
4zlib
5--FILE--
6<?php
7
8ini_set('memory_limit', '64M');
9
10$deflator = deflate_init(ZLIB_ENCODING_RAW);
11
12$bytes = str_repeat("*", 65536);
13
14// this crashes after about 500 iterations if PHP is
15// configured for 64M
16for ($i = 0; $i < 1000; $i++) {
17    $output = deflate_add(
18        $deflator,
19        $bytes,
20        ZLIB_SYNC_FLUSH
21    );
22}
23echo "Completed\n";
24?>
25--EXPECT--
26Completed
27