1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 13:31:27 +02:00
Files
archived-php-src/ext/standard/tests/file/bug52820.phpt
Pierrick Charron 59a4514dc0 Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
  Fix test to work on every libcurl version
  - Fixed typo on "SKIPIF" (causing make test to abort on some systems)

Conflicts:
	tests/output/bug63377.phpt
2012-12-21 12:24:52 -05:00

72 lines
2.1 KiB
PHP

--TEST--
Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)
--SKIPIF--
<?php
if (!function_exists('leak_variable'))
die("skip only for debug builds");
/* unfortunately no standard function does a cast to FILE*, so we need
* curl to test this */
if (!extension_loaded("curl")) exit("skip curl extension not loaded");
$handle=curl_init('http://127.0.0.1:37349/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
die("skip fopencookie not supported on this platform");
--FILE--
<?php
function do_stuff($url) {
$handle=curl_init('http://127.0.0.1:37349/');
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
curl_exec($handle);
echo "About to rewind!\n";
rewind($o);
echo stream_get_contents($o);
return $o;
}
echo "temp stream (close after):\n";
fclose(do_stuff("php://temp"));
echo "\nmemory stream (close after):\n";
fclose(do_stuff("php://memory"));
echo "\ntemp stream (leak):\n";
leak_variable(do_stuff("php://temp"), true);
echo "\nmemory stream (leak):\n";
leak_variable(do_stuff("php://memory"), true);
echo "\nDone.\n";
--EXPECTF--
temp stream (close after):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
memory stream (close after):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
temp stream (leak):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
memory stream (leak):
About to rewind!
* About to connect() to 127.0.0.1 port 37349%r.*%r
* Trying 127.0.0.1...%A* Connection refused
* couldn't connect to host%S
* Closing connection #0
Done.