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