From b8e70ac0416d00d77c17f5465c35fddb9bd0a3b6 Mon Sep 17 00:00:00 2001 From: reeze Date: Fri, 20 Apr 2012 17:33:26 +0800 Subject: [PATCH 1/2] Bug #61785 (Memory leak when access a non-exists file without route) --- sapi/cli/php_cli_server.c | 3 ++ sapi/cli/tests/php_cli_server_018.phpt | 39 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 sapi/cli/tests/php_cli_server_018.phpt diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 79ccea37d7a69..647d37e14e966 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -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); diff --git a/sapi/cli/tests/php_cli_server_018.phpt b/sapi/cli/tests/php_cli_server_018.phpt new file mode 100644 index 0000000000000..5df685bb23ac1 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_018.phpt @@ -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-- + +--FILE-- + +--EXPECTF-- +HTTP/1.1 404 Not Found From 459832bbc72b55768ac5fa1478b5486318a5b024 Mon Sep 17 00:00:00 2001 From: reeze Date: Fri, 20 Apr 2012 17:40:11 +0800 Subject: [PATCH 2/2] Fixed typo in test: sapi/cli/tests/php_cli_server_016.phpt --- sapi/cli/tests/php_cli_server_016.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/cli/tests/php_cli_server_016.phpt b/sapi/cli/tests/php_cli_server_016.phpt index 3fd065a1c68d7..e64615fd8c77d 100644 --- a/sapi/cli/tests/php_cli_server_016.phpt +++ b/sapi/cli/tests/php_cli_server_016.phpt @@ -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--