From: Daniel Stenberg Date: Tue, 28 Oct 2025 10:56:03 +0000 (+0100) Subject: cookie: remove the temporary file on (all) errors X-Git-Tag: rc-8_17_0-3~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9308ea22e8299fb79f4acd0398829cbe37a3fb1c;p=thirdparty%2Fcurl.git cookie: remove the temporary file on (all) errors Fixes #19267 Reported-by: Harry Sintonen Closes #19268 --- diff --git a/lib/cookie.c b/lib/cookie.c index 9b89b7df70..35b252971d 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -1595,7 +1595,6 @@ static CURLcode cookie_output(struct Curl_easy *data, curlx_fclose(out); out = NULL; if(tempstore && Curl_rename(tempstore, filename)) { - unlink(tempstore); error = CURLE_WRITE_ERROR; goto error; } @@ -1612,7 +1611,10 @@ static CURLcode cookie_output(struct Curl_easy *data, error: if(out && !use_stdout) curlx_fclose(out); - free(tempstore); + if(tempstore) { + unlink(tempstore); + free(tempstore); + } return error; }