xref: /PHP-8.0/ext/curl/tests/bug45161.phpt (revision 079905ac)
1--TEST--
2Bug #45161 (Reusing a curl handle leaks memory)
3--SKIPIF--
4<?php
5include 'skipif.inc';
6?>
7--FILE--
8<?php
9include 'server.inc';
10$host = curl_cli_server_start();
11
12// Fill memory for test
13$ch = curl_init();
14$fp = fopen(PHP_OS_FAMILY === 'Windows' ? 'nul' : '/dev/null', 'w');
15
16/*
17$i = $start = $end = 100000.00;
18for ($i = 0; $i < 100; $i++) {
19    curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/');
20    curl_setopt($ch, CURLOPT_FILE, $fp);
21    curl_exec($ch);
22}
23*/
24
25// Start actual test
26$start = memory_get_usage() + 1024;
27for($i = 0; $i < 1024; $i++) {
28    curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc");
29    curl_setopt($ch, CURLOPT_FILE, $fp);
30    curl_exec($ch);
31}
32if ($start < memory_get_usage()) {
33    echo 'FAIL';
34} else {
35    echo 'PASS';
36}
37echo "\n";
38fclose($fp);
39unset($fp);
40?>
41--EXPECT--
42PASS
43