Mercurial > dovecot > core-2.2
changeset 19782:9d8d3589d2fb
lib-http: server: Implicitly free a request response structure when a new (failure) response is started.
author | Stephan Bosch <stephan@rename-it.nl> |
---|---|
date | Sat, 20 Feb 2016 19:35:12 +0200 |
parents | 79d4ae42692c |
children | ef55202a5148 |
files | src/lib-http/http-server-response.c |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-http/http-server-response.c Sat Feb 20 13:40:18 2016 +0200 +++ b/src/lib-http/http-server-response.c Sat Feb 20 19:35:12 2016 +0200 @@ -49,9 +49,19 @@ { struct http_server_response *resp; - i_assert(req->response == NULL); + if (req->response == NULL) { + resp = req->response = p_new + (req->pool, struct http_server_response, 1); + } else { + /* was already composing a response, but decided to + start a new one (would usually be a failure response) + */ + resp = req->response; + i_assert(!resp->submitted); + http_server_response_free(resp); + memset(resp, 0, sizeof(*resp)); + } - resp = req->response = p_new(req->pool, struct http_server_response, 1); resp->request = req; resp->status = status; resp->reason = p_strdup(req->pool, reason);