xref: /PHP-5.3/ext/curl/tests/bug48203.phpt (revision 33bee161)
1--TEST--
2Bug #48203 (Crash when CURLOPT_STDERR is set to regular file)
3--SKIPIF--
4<?php
5if (!extension_loaded("curl")) {
6	exit("skip curl extension not loaded");
7}
8if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  {
9	exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
10}
11?>
12--FILE--
13<?php
14
15$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
16
17$ch = curl_init();
18
19curl_setopt($ch, CURLOPT_VERBOSE, 1);
20curl_setopt($ch, CURLOPT_STDERR, $fp);
21curl_setopt($ch, CURLOPT_URL, getenv('PHP_CURL_HTTP_REMOTE_SERVER'));
22
23fclose($fp); // <-- premature close of $fp caused a crash!
24
25curl_exec($ch);
26curl_close($ch);
27
28echo "Ok\n";
29
30?>
31--CLEAN--
32<?php @unlink(dirname(__FILE__) . '/bug48203.tmp'); ?>
33--EXPECTF--
34Warning: curl_exec(): CURLOPT_STDERR resource has gone away, resetting to stderr in %sbug48203.php on line %d
35%A
36Ok
37