1--TEST-- 2Bug #52820 (writes to fopencookie FILE* not committed when seeking the stream) 3--EXTENSIONS-- 4curl 5zend_test 6--SKIPIF-- 7<?php 8/* unfortunately no standard function does a cast to FILE*, so we need 9 * curl to test this */ 10$handle=curl_init('file:///i_dont_exist/'); 11curl_setopt($handle, CURLOPT_VERBOSE, true); 12curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); 13if (!@curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+"))) 14 die("skip fopencookie not supported on this platform"); 15if (getenv('CIRCLECI')) die('xfail Broken on CircleCI'); 16?> 17--FILE-- 18<?php 19function do_stuff($url) { 20 $handle=curl_init('file:///i_dont_exist/'); 21 curl_setopt($handle, CURLOPT_VERBOSE, true); 22 curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); 23 curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+")); 24 curl_exec($handle); 25 echo "About to rewind!\n"; 26 rewind($o); 27 echo stream_get_contents($o); 28 return $o; 29} 30 31echo "temp stream (close after):\n"; 32fclose(do_stuff("php://temp")); 33 34echo "\nmemory stream (close after):\n"; 35fclose(do_stuff("php://memory")); 36 37echo "\ntemp stream (leak):\n"; 38zend_leak_variable(do_stuff("php://temp")); 39 40echo "\nmemory stream (leak):\n"; 41zend_leak_variable(do_stuff("php://memory")); 42 43echo "\nDone.\n"; 44?> 45--EXPECTREGEX-- 46temp stream \(close after\): 47About to rewind! 48(\* processing: file:\/\/\/i_dont_exist\/\n)?\* Couldn't open file \/i_dont_exist\/ 49\* [Cc]losing connection( #?-?\d+)? 50 51memory stream \(close after\): 52About to rewind! 53(\* processing: file:\/\/\/i_dont_exist\/\n)?\* Couldn't open file \/i_dont_exist\/ 54\* [Cc]losing connection( #?-?\d+)? 55 56temp stream \(leak\): 57About to rewind! 58(\* processing: file:\/\/\/i_dont_exist\/\n)?\* Couldn't open file \/i_dont_exist\/ 59\* [Cc]losing connection( #?-?\d+)? 60 61memory stream \(leak\): 62About to rewind! 63(\* processing: file:\/\/\/i_dont_exist\/\n)?\* Couldn't open file \/i_dont_exist\/ 64\* [Cc]losing connection( #?-?\d+)? 65 66Done\. 67