cookie: CURLOPT_COOKIEFILE set to NULL switches off cookies

Add test 676 to verify that setting CURLOPT_COOKIEFILE to NULL again clears
the cookiejar from memory.

Reported-by: Stefan Karpinski
Fixes #6889
Closes #6891
This commit is contained in:
Daniel Stenberg 2021-04-14 09:15:19 +02:00
parent 566b74a0e1
commit 520bd5225c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 175 additions and 3 deletions

View file

@ -752,6 +752,20 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
}
data->state.cookielist = cl; /* store the list for later use */
}
else {
/* clear the list of cookie files */
curl_slist_free_all(data->state.cookielist);
data->state.cookielist = NULL;
if(!data->share || !data->share->cookies) {
/* throw away all existing cookies if this isn't a shared cookie
container */
Curl_cookie_clearall(data->cookies);
Curl_cookie_cleanup(data->cookies);
}
/* disable the cookie engine */
data->cookies = NULL;
}
break;
case CURLOPT_COOKIEJAR: