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