Merge pull request #913 from whatdoineed2do/http-slist-leak

[http] leak fix for curl_slist_append()
This commit is contained in:
ejurgensen 2020-02-29 18:22:09 +01:00 committed by GitHub
commit eb049489b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -370,9 +370,9 @@ https_client_request_impl(struct http_client_ctx *ctx)
curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent);
curl_easy_setopt(curl, CURLOPT_URL, ctx->url);
headers = NULL;
if (ctx->output_headers)
{
headers = NULL;
for (okv = ctx->output_headers->head; okv; okv = okv->next)
{
snprintf(header, sizeof(header), "%s: %s", okv->name, okv->value);
@ -400,6 +400,7 @@ https_client_request_impl(struct http_client_ctx *ctx)
if (res != CURLE_OK)
{
DPRINTF(E_LOG, L_HTTP, "Request to %s failed: %s\n", ctx->url, curl_easy_strerror(res));
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return -1;
}
@ -408,6 +409,7 @@ https_client_request_impl(struct http_client_ctx *ctx)
ctx->response_code = (int) response_code;
curl_headers_save(ctx->input_headers, curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;