Skip to content

Commit

Permalink
lib-http: server: Implicitly free a request response structure when a…
Browse files Browse the repository at this point in the history
… new (failure) response is started.
  • Loading branch information
stephanbosch authored and sirainen committed Feb 20, 2016
1 parent 0755a3b commit c0a8031
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib-http/http-server-response.c
Expand Up @@ -49,9 +49,19 @@ http_server_response_create(struct http_server_request *req,
{
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);
Expand Down

0 comments on commit c0a8031

Please sign in to comment.