Skip to content

Fixed Bug #61785 (Memory leak when access a non-exists file without route) #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1781,11 +1781,14 @@ static int php_cli_server_send_error_page(php_cli_server *server, php_cli_server
php_output_discard(TSRMLS_C);
if (!SG(sapi_started)) {
static int (*send_header_func)(sapi_headers_struct * TSRMLS_DC);
unsigned char send_default_content_type = SG(sapi_headers).send_default_content_type;
send_header_func = sapi_module.send_headers;
/* we don't want the header to be sent now */
sapi_module.send_headers = sapi_cli_server_discard_headers;
SG(sapi_headers).send_default_content_type = 0;
php_output_deactivate(TSRMLS_C);
sapi_module.send_headers = send_header_func;
SG(sapi_headers).send_default_content_type = send_default_content_type;
}
if (style && Z_STRVAL_P(style)) {
char *block = pestrndup(Z_STRVAL_P(style), Z_STRLEN_P(style), 1);
Expand Down
2 changes: 1 addition & 1 deletion sapi/cli/tests/php_cli_server_016.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Bug #60591 (Memory leak when access a non-exists file)
--DESCRIPTION--
this is a indirect test for bug 50691, since mem leak is reproted in the server side
this is an indirect test for bug 60691, since mem leak is reproted in the server side
and require php compiled with --enable-debug
--SKIPIF--
<?php
Expand Down
39 changes: 39 additions & 0 deletions sapi/cli/tests/php_cli_server_018.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
Bug #60591 (Memory leak when access a non-exists file without router)
--DESCRIPTION--
this is an indirect test for bug 60691, since mem leak is reproted in the server side
and require php compiled with --enable-debug
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
php_cli_server_start(NULL, true);

list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port)?:80;

$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
die("connect failed");
}

if(fwrite($fp, <<<HEADER
POST /no-exists.jpg HTTP/1.1
Host: {$host}


HEADER
)) {
while (!feof($fp)) {
echo fgets($fp);
break;
}
}

fclose($fp);
?>
--EXPECTF--
HTTP/1.1 404 Not Found