xref: /PHP-5.5/ext/curl/tests/bug52827.phpt (revision 56ea9873)
1--TEST--
2Bug #52827 (curl_setopt with CURLOPT_STDERR erroneously increments the resource refcount)
3--SKIPIF--
4<?php
5
6if (!extension_loaded('curl')) {
7	exit("skip curl extension not loaded");
8}
9
10?>
11--FILE--
12<?php
13$s = fopen('php://temp/maxmemory=1024','wb+');
14
15/* force conversion of inner stream to STDIO.
16 * This is not necessary in Windows because the
17 * cast to a FILE* handle in curl_setopt already
18 * forces the conversion in that platform. The
19 * reason for this conversion is that the memory
20 * stream has an ugly but working mechanism to
21 * prevent being double freed when it's encapsulated,
22 * while STDIO streams don't. */
23$i = 0;
24while ($i++ < 5000) {
25fwrite($s, str_repeat('a',1024));
26}
27$handle=curl_init('http://www.example.com');
28curl_setopt($handle, CURLOPT_STDERR, $s);
29
30echo "Done.";
31--EXPECTF--
32Done.
33