Skip to content

Commit c9a3db3

Browse files
mkauficing
authored andcommitted
md_curl: reset curl handle before reusing it
1 parent 8cc0ec9 commit c9a3db3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Fix a small memory leak when using OpenSSL's BIGNUMs. [Theo Buehler]
2+
* Fix reuse of curl easy handles by resetting them. [Michael Kaufmann]
23

34
v2.6.5
45
----------------------------------------------------------------------------------------------------

src/md_curl.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,19 @@ static apr_status_t internals_setup(md_http_request_t *req)
255255
rv = APR_EGENERAL;
256256
goto leave;
257257
}
258-
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_cb);
259-
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
260-
curl_easy_setopt(curl, CURLOPT_READFUNCTION, req_data_cb);
261-
curl_easy_setopt(curl, CURLOPT_READDATA, NULL);
262-
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, resp_data_cb);
263-
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
264258
}
265259
else {
266260
md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, req->pool, "reusing curl instance from http");
261+
curl_easy_reset(curl);
267262
}
268263

264+
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_cb);
265+
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
266+
curl_easy_setopt(curl, CURLOPT_READFUNCTION, req_data_cb);
267+
curl_easy_setopt(curl, CURLOPT_READDATA, NULL);
268+
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, resp_data_cb);
269+
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
270+
269271
internals = apr_pcalloc(req->pool, sizeof(*internals));
270272
internals->curl = curl;
271273

0 commit comments

Comments
 (0)