Skip to content

Commit

Permalink
url: fix cookielist memleak when curl_easy_reset
Browse files Browse the repository at this point in the history
- Free set.cookelist in Curl_freeset instead of Curl_close.

Prior to this change the cookielist linked list wasn't freed by
curl_easy_reset which calls Curl_freeset to free all set.

Bug: curl#10694 (comment)
Reported-by: Sergey Ryabinin

Closes curl#10709
  • Loading branch information
jay committed Mar 10, 2023
1 parent 297ad6a commit b559ef6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/url.c
Expand Up @@ -341,6 +341,11 @@ void Curl_freeset(struct Curl_easy *data)
data->state.url = NULL;

Curl_mime_cleanpart(&data->set.mimepost);

#ifndef CURL_DISABLE_COOKIES
curl_slist_free_all(data->set.cookielist);
data->set.cookielist = NULL;
#endif
}

/* free the URL pieces */
Expand Down Expand Up @@ -431,9 +436,6 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_dyn_free(&data->state.headerb);
Curl_safefree(data->state.ulbuf);
Curl_flush_cookies(data, TRUE);
#ifndef CURL_DISABLE_COOKIES
curl_slist_free_all(data->set.cookielist); /* clean up list */
#endif
Curl_altsvc_save(data, data->asi, data->set.str[STRING_ALTSVC]);
Curl_altsvc_cleanup(&data->asi);
Curl_hsts_save(data, data->hsts, data->set.str[STRING_HSTS]);
Expand Down

0 comments on commit b559ef6

Please sign in to comment.