summaryrefslogtreecommitdiff
path: root/ext/curl/tests/bug45161.phpt
blob: bfcd244004cac9814b8270cb487905e876acede3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
Bug #45161 (Reusing a curl handle leaks memory)
--SKIPIF--
<?php 
if (substr(PHP_OS, 0, 3) == 'WIN') {
	exit("skip not for Windows");
}
if (!extension_loaded("curl")) {
	exit("skip curl extension not loaded");
}
$curl_version = curl_version(); 
if ($curl_version['version_number'] < 0x071100) {
	exit("skip: test works only with curl >= 7.17.0"); 
}
?>
--FILE--
<?php

// Fill memory for test
$ch = curl_init();
$fp = fopen('/dev/null', 'w');

/*
$i = $start = $end = 100000.00;
for ($i = 0; $i < 100; $i++) {
	curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/');
	curl_setopt($ch, CURLOPT_FILE, $fp);
	curl_exec($ch);
}
*/

// Start actual test
$start = memory_get_usage() + 1024;
for($i = 0; $i < 1024; $i++) {
	curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:9/');
	curl_setopt($ch, CURLOPT_FILE, $fp);
	curl_exec($ch);
}
if ($start < memory_get_usage()) {
	echo 'FAIL';
} else {
	echo 'PASS';
}
echo "\n";
fclose($fp);
unset($fp);
?>
--EXPECT--
PASS