diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-11-15 18:22:52 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-11-15 18:22:52 +0000 |
commit | e10454ded867c286a21c949df9eab55f510b368d (patch) | |
tree | cbe66235cf15030cfaf5e6916b6ab769411bdf07 /ext | |
parent | 565c484222e21667dcd55ea78889e06117266f1d (diff) | |
download | php-git-e10454ded867c286a21c949df9eab55f510b368d.tar.gz |
- Fixed bug #52820 (writes to fopencookie FILE* not commited when seeking the
stream).
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/tests/file/bug52820.phpt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/ext/standard/tests/file/bug52820.phpt b/ext/standard/tests/file/bug52820.phpt new file mode 100644 index 0000000000..a631bef4b3 --- /dev/null +++ b/ext/standard/tests/file/bug52820.phpt @@ -0,0 +1,69 @@ +--TEST--
+Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)
+--SKIPIF--
+<?php
+/* 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";
+--EXPECT--
+temp stream (close after):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349 (#0)
+* Trying 127.0.0.1... * Connection refused
+* couldn't connect to host
+* Closing connection #0
+
+memory stream (close after):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349 (#0)
+* Trying 127.0.0.1... * Connection refused
+* couldn't connect to host
+* Closing connection #0
+
+temp stream (leak):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349 (#0)
+* Trying 127.0.0.1... * Connection refused
+* couldn't connect to host
+* Closing connection #0
+
+memory stream (leak):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349 (#0)
+* Trying 127.0.0.1... * Connection refused
+* couldn't connect to host
+* Closing connection #0
+
+Done.
|