mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Merge branch 'PHP-5.4.40' into PHP-5.5.24
* PHP-5.4.40: fix memory leak & add test Fix tests
This commit is contained in:
commit
ba15e8dfd0
6 changed files with 72 additions and 26 deletions
|
@ -3,7 +3,7 @@ Testing that imageloadfont() breaks on non-string first parameter
|
||||||
--CREDITS--
|
--CREDITS--
|
||||||
Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
|
Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
if (!extension_loaded("gd")) die("skip GD not present");
|
if (!extension_loaded("gd")) die("skip GD not present");
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
|
@ -11,5 +11,5 @@ Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
|
||||||
var_dump( imageloadfont(array()) );
|
var_dump( imageloadfont(array()) );
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Warning: imageloadfont() expects parameter 1 to be string, array given in %s on line %d
|
Warning: imageloadfont() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
|
@ -922,8 +922,13 @@ out:
|
||||||
if (transfer_encoding) {
|
if (transfer_encoding) {
|
||||||
php_stream_filter_append(&stream->readfilters, transfer_encoding);
|
php_stream_filter_append(&stream->readfilters, transfer_encoding);
|
||||||
}
|
}
|
||||||
} else if (transfer_encoding) {
|
} else {
|
||||||
php_stream_filter_free(transfer_encoding TSRMLS_CC);
|
if(response_header) {
|
||||||
|
Z_DELREF_P(response_header);
|
||||||
|
}
|
||||||
|
if (transfer_encoding) {
|
||||||
|
php_stream_filter_free(transfer_encoding TSRMLS_CC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
|
|
41
ext/standard/tests/http/bug69337.phpt
Normal file
41
ext/standard/tests/http/bug69337.phpt
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #69337 (Stream context leaks when http request fails)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:22345'); ?>
|
||||||
|
--INI--
|
||||||
|
allow_url_fopen=1
|
||||||
|
allow_url_include=1
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require 'server.inc';
|
||||||
|
|
||||||
|
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
|
||||||
|
{
|
||||||
|
if($notification_code == STREAM_NOTIFY_REDIRECTED) {
|
||||||
|
// $http_response_header is now a string, but will be used as an array
|
||||||
|
// by php_stream_url_wrap_http_ex() later on
|
||||||
|
$GLOBALS['http_response_header'] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\0\0\0\0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ctx = stream_context_create();
|
||||||
|
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
|
||||||
|
|
||||||
|
$responses = array(
|
||||||
|
"data://text/plain,HTTP/1.0 302 Found\r\nLocation: http://127.0.0.1:22345/try-again\r\n\r\n",
|
||||||
|
"data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n",
|
||||||
|
);
|
||||||
|
|
||||||
|
$pid = http_server("tcp://127.0.0.1:22345", $responses, $output);
|
||||||
|
|
||||||
|
$f = file_get_contents('http://127.0.0.1:22345/', 0, $ctx);
|
||||||
|
|
||||||
|
http_server_kill($pid);
|
||||||
|
var_dump($f);
|
||||||
|
?>
|
||||||
|
==DONE==
|
||||||
|
--EXPECTF--
|
||||||
|
string(26) "HTTP/1.0 404 Not Found
|
||||||
|
|
||||||
|
"
|
||||||
|
==DONE==
|
|
@ -1,17 +1,17 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test gzopen() function : usage variation
|
Test gzopen() function : usage variation
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
if (!extension_loaded("zlib")) {
|
if (!extension_loaded("zlib")) {
|
||||||
print "skip - zlib extension not loaded";
|
print "skip - zlib extension not loaded";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
/* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
|
||||||
* Description: Open a .gz-file and return a .gz-file pointer
|
* Description: Open a .gz-file and return a .gz-file pointer
|
||||||
* Source code: ext/zlib/zlib.c
|
* Source code: ext/zlib/zlib.c
|
||||||
* Alias to functions:
|
* Alias to functions:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo "*** Testing gzopen() : usage variation ***\n";
|
echo "*** Testing gzopen() : usage variation ***\n";
|
||||||
|
@ -102,9 +102,9 @@ $inputs = array(
|
||||||
|
|
||||||
// unset data
|
// unset data
|
||||||
'unset var' => @$unset_var,
|
'unset var' => @$unset_var,
|
||||||
|
|
||||||
// resource variable
|
// resource variable
|
||||||
'resource' => $fp
|
'resource' => $fp
|
||||||
);
|
);
|
||||||
|
|
||||||
// loop through each element of the array for filename
|
// loop through each element of the array for filename
|
||||||
|
@ -158,19 +158,19 @@ Error: 2 - gzopen(0.5): failed to open stream: No such file or directory, %s(%d)
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--empty array--
|
--empty array--
|
||||||
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
|
Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
--int indexed array--
|
--int indexed array--
|
||||||
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
|
Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
--associative array--
|
--associative array--
|
||||||
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
|
Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
--nested arrays--
|
--nested arrays--
|
||||||
Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
|
Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
--uppercase NULL--
|
--uppercase NULL--
|
||||||
|
@ -210,7 +210,7 @@ Error: 2 - gzopen(Class A object): failed to open stream: No such file or direct
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--instance of classWithoutToString--
|
--instance of classWithoutToString--
|
||||||
Error: 2 - gzopen() expects parameter 1 to be string, object given, %s(%d)
|
Error: 2 - gzopen() expects parameter 1 to be a valid path, object given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
--undefined var--
|
--undefined var--
|
||||||
|
@ -222,7 +222,7 @@ Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--resource--
|
--resource--
|
||||||
Error: 2 - gzopen() expects parameter 1 to be string, resource given, %s(%d)
|
Error: 2 - gzopen() expects parameter 1 to be a valid path, resource given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
===DONE===
|
===DONE===
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,15 @@ foreach ( $variation as $var ) {
|
||||||
===DONE===
|
===DONE===
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
|
|
||||||
Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
|
Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
|
Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
|
Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
||||||
Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
|
Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
===DONE===
|
===DONE===
|
||||||
|
|
|
@ -45,5 +45,5 @@ foreach ( $variation as $var ) {
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Error: 2 - readgzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
|
Error: 2 - readgzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
|
||||||
bool(false)
|
bool(false)
|
||||||
Error: 2 - readgzfile() expects parameter 1 to be string, object given, %s(%d)
|
Error: 2 - readgzfile() expects parameter 1 to be a valid path, object given, %s(%d)
|
||||||
NULL
|
NULL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue