From: Stephan Bosch Date: Sat, 17 Feb 2018 14:08:44 +0000 (+0100) Subject: lib-http: client: Hold reference to the connection while sending the next request. X-Git-Tag: 2.3.1~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c13f150f61b32d5d42ff30b564be1056a0776d34;p=thirdparty%2Fdovecot%2Fcore.git lib-http: client: Hold reference to the connection while sending the next request. Subsequent changes may cause the connection to be destroyed while sending. --- diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index 81e07c2592..2a8e1358d6 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -596,6 +596,7 @@ http_client_connection_continue_timeout(struct http_client_connection *conn) int http_client_connection_next_request(struct http_client_connection *conn) { + struct http_client_connection *tmp_conn; struct http_client_peer *peer = conn->peer; struct http_client_peer_shared *pshared = conn->ppool->peer; struct http_client_request *req = NULL; @@ -631,7 +632,10 @@ int http_client_connection_next_request(struct http_client_connection *conn) e_debug(conn->event, "Claimed request %s", http_client_request_label(req)); - if (http_client_request_send(req, pipelined) < 0) + tmp_conn = conn; + http_client_connection_ref(tmp_conn); + ret = http_client_request_send(req, pipelined); + if (!http_client_connection_unref(&tmp_conn) || ret < 0) return -1; if (req->connect_tunnel)