1--TEST-- 2Bug #60570 (Stream context leaks when http request fails) 3--SKIPIF-- 4<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?> 5--INI-- 6allow_url_fopen=1 7allow_url_include=1 8--FILE-- 9<?php 10require 'server.inc'; 11 12function do_test() { 13 14 $responses = array( 15 "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", 16 "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", 17 "data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n" 18 ); 19 20 $pid = http_server("tcp://127.0.0.1:12342", $responses, $output); 21 22 $a = $b = null; 23 24 $i = 3; 25 while ($i--) { 26 $context = stream_context_create(array('http'=>array('timeout'=>1))); 27 file_get_contents('http://127.0.0.1:12342/', 0, $context); 28 unset($context); 29 30 $b = $a; 31 $a = memory_get_usage(); 32 } 33 34 http_server_kill($pid); 35 36 echo "leak? penultimate iteration: $b, last one: $a\n"; 37 var_dump($a == $b); 38} 39 40do_test(); 41 42--EXPECTF-- 43Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found 44 in %s on line %d 45 46Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found 47 in %s on line %d 48 49Warning: file_get_contents(http://127.0.0.1:12342/): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found 50 in %s on line %d 51leak? penultimate iteration: %d, last one: %d 52bool(true) 53 54