Browse Source

duphandle: also free 'outcurl->cookies' in error path

Fixes memory-leak when OOM mid-function

Use plain free instead of safefree, since the entire struct is
freed below.

Remove some free calls that is already freed in Curl_freeset()

Closes #12329
Daniel Stenberg 6 months ago
parent
commit
d1820768cc
1 changed files with 2 additions and 5 deletions
  1. 2 5
      lib/easy.c

+ 2 - 5
lib/easy.c

@@ -985,13 +985,10 @@ fail:
 
   if(outcurl) {
 #ifndef CURL_DISABLE_COOKIES
-    curl_slist_free_all(outcurl->state.cookielist);
-    outcurl->state.cookielist = NULL;
+    free(outcurl->cookies);
 #endif
-    Curl_safefree(outcurl->state.buffer);
+    free(outcurl->state.buffer);
     Curl_dyn_free(&outcurl->state.headerb);
-    Curl_safefree(outcurl->state.url);
-    Curl_safefree(outcurl->state.referer);
     Curl_altsvc_cleanup(&outcurl->asi);
     Curl_hsts_cleanup(&outcurl->hsts);
     Curl_freeset(outcurl);