From be2df43b08cf13b9a5791ff5eb827a125115ef52 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 30 Jul 2021 15:36:12 +0200 Subject: [PATCH] Fix #78919: CLI server: insufficient cleanup if request startup fails We need to run the full `php_cli_server_request_shutdown()` in case of failing `php_cli_server_request_startup()`. Patch contributed by @cataphract. Closes GH-7322. --- NEWS | 2 ++ sapi/cli/php_cli_server.c | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index cf3853795c9..d0e7b815108 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ PHP NEWS (krakjoe) . Fixed bug #81192 ("Declaration should be compatible with" gives incorrect line number with traits). (Nikita) + . Fixed bug #78919 (CLI server: insufficient cleanup if request startup + fails). (cataphract, cmb) - Date: . Fixed bug #79580 (date_create_from_format misses leap year). (Derick) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index eb01dac2496..4ebe8fe654c 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -2126,8 +2126,6 @@ static int php_cli_server_request_startup(php_cli_server *server, php_cli_server } SG(sapi_headers).http_response_code = 200; if (FAILURE == php_request_startup()) { - /* should never be happen */ - destroy_request_info(&SG(request_info)); return FAILURE; } PG(during_request_startup) = 0; @@ -2198,9 +2196,7 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client if (server->router || !is_static_file) { if (FAILURE == php_cli_server_request_startup(server, client)) { - SG(server_context) = NULL; - php_cli_server_close_connection(server, client); - destroy_request_info(&SG(request_info)); + php_cli_server_request_shutdown(server, client); return SUCCESS; } }