forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug52827.phpt
32 lines (28 loc) · 819 Bytes
/
bug52827.phpt
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
--TEST--
Bug #52827 (curl_setopt with CURLOPT_STDERR erroneously increments the resource refcount)
--SKIPIF--
<?php
if (!extension_loaded('curl')) {
exit("skip curl extension not loaded");
}
?>
--FILE--
<?php
$s = fopen('php://temp/maxmemory=1024','wb+');
/* force conversion of inner stream to STDIO.
* This is not necessary in Windows because the
* cast to a FILE* handle in curl_setopt already
* forces the conversion in that platform. The
* reason for this conversion is that the memory
* stream has an ugly but working mechanism to
* prevent being double freed when it's encapsulated,
* while STDIO streams don't. */
$i = 0;
while ($i++ < 5000) {
fwrite($s, str_repeat('a',1024));
}
$handle=curl_init('http://www.example.com');
curl_setopt($handle, CURLOPT_STDERR, $s);
echo "Done.";
--EXPECTF--
Done.