From: Stephan Bosch Date: Mon, 8 Feb 2016 21:52:38 +0000 (+0100) Subject: lib-http: server: Fixed memory problem reported by Valgrind, which was caused by... X-Git-Tag: 2.2.22.rc1~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b498cc3045c2b48a096bf5a8518526c9606e4e01;p=thirdparty%2Fdovecot%2Fcore.git lib-http: server: Fixed memory problem reported by Valgrind, which was caused by the request being freed too early while sending a response. Fixed by referencing the request while it is being sent. --- diff --git a/src/lib-http/http-server-connection.c b/src/lib-http/http-server-connection.c index 308925e75e..699daf80cb 100644 --- a/src/lib-http/http-server-connection.c +++ b/src/lib-http/http-server-connection.c @@ -594,6 +594,7 @@ http_server_connection_next_response(struct http_server_connection *conn) { struct http_server_request *req; const char *error = NULL; + int ret; if (conn->output_locked) return FALSE; @@ -645,7 +646,11 @@ http_server_connection_next_response(struct http_server_connection *conn) http_server_connection_timeout_start(conn); - if (http_server_response_send(req->response, &error) < 0) { + http_server_request_ref(req); + ret = http_server_response_send(req->response, &error); + http_server_request_unref(&req); + + if (ret < 0) { if (error != NULL) { http_server_connection_error(conn, "Failed to send response: %s", error);