diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-04-14 09:15:19 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-04-14 23:09:36 +0200 |
commit | 520bd5225c70a5c4cceee08f1aa7447eb0ec6653 (patch) | |
tree | 7a0a8b9f71db37e6311bc30004892dea3bc1dc45 /lib | |
parent | 566b74a0e19b9aa610f4931e5bfd339bcf8e9147 (diff) | |
download | curl-520bd5225c70a5c4cceee08f1aa7447eb0ec6653.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/setopt.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/setopt.c b/lib/setopt.c index 022dd3800..5944482a8 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -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: |