xref: /PHP-5.3/ext/curl/tests/bug45161.phpt (revision 13dce00c)
1--TEST--
2Bug #45161 (Reusing a curl handle leaks memory)
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6	exit("skip not for Windows");
7}
8if (!extension_loaded("curl")) {
9	exit("skip curl extension not loaded");
10}
11if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  {
12	exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
13}
14$curl_version = curl_version();
15if ($curl_version['version_number'] < 0x071100) {
16	exit("skip: test works only with curl >= 7.17.0");
17}
18?>
19--FILE--
20<?php
21
22// Fill memory for test
23$ch = curl_init();
24$fp = fopen('/dev/null', 'w');
25
26/*
27$i = $start = $end = 100000.00;
28for ($i = 0; $i < 100; $i++) {
29	curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/');
30	curl_setopt($ch, CURLOPT_FILE, $fp);
31	curl_exec($ch);
32}
33*/
34
35// Start actual test
36$start = memory_get_usage() + 1024;
37for($i = 0; $i < 1024; $i++) {
38	curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/');
39	curl_setopt($ch, CURLOPT_FILE, $fp);
40	curl_exec($ch);
41}
42if ($start < memory_get_usage()) {
43	echo 'FAIL';
44} else {
45	echo 'PASS';
46}
47echo "\n";
48fclose($fp);
49unset($fp);
50?>
51--EXPECT--
52PASS
53