]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_cfgable: free ssl-sessions at exit
authorDaniel Stenberg <daniel@haxx.se>
Wed, 19 Nov 2025 07:32:41 +0000 (08:32 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 19 Nov 2025 11:58:15 +0000 (12:58 +0100)
Also free the memory correctly in tool_ssls_load

Closes #19602

src/tool_cfgable.c
src/tool_cfgable.h
src/tool_ssls.c

index 2ddb0ad2fcfc3bbc99d760f217b605849d80529b..086e4ac21659c274ba11d6740cee5d7f89bf3c13 100644 (file)
@@ -260,6 +260,7 @@ static void free_globalconfig(void)
     curlx_fclose(global->trace_stream);
   global->trace_stream = NULL;
 
+  tool_safefree(global->ssl_sessions);
   tool_safefree(global->libcurl);
 #ifdef _WIN32
   free(global->term.buf);
index dc78f2db44f646d50f1e56f5113088d32a8e1d33..717d35a1f522d7c1092d85ff7441c8e837c2ab9e 100644 (file)
@@ -29,6 +29,7 @@
 #include "tool_sdecls.h"
 #include "tool_urlglob.h"
 #include "var.h"
+#include "memdebug.h" /* keep this as LAST include */
 
 /* the type we use for storing a single boolean bit */
 #ifndef BIT
index 2b8cc1067266a6b9143561e28c262393b945d423..ab78014c0a868b653b453b3cf73b9244071f2340 100644 (file)
@@ -80,8 +80,8 @@ CURLcode tool_ssls_load(struct OperationConfig *config,
   i = imported = 0;
   while(my_get_line(fp, &buf, &error)) {
     ++i;
-    curl_free(shmac);
-    curl_free(sdata);
+    tool_safefree(shmac);
+    tool_safefree(sdata);
     line = curlx_dyn_ptr(&buf);
 
     c = memchr(line, ':', strlen(line));
@@ -125,8 +125,8 @@ out:
   if(fp)
     curlx_fclose(fp);
   curlx_dyn_free(&buf);
-  curl_free(shmac);
-  curl_free(sdata);
+  free(shmac);
+  free(sdata);
   return r;
 }
 
@@ -165,7 +165,7 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr,
     goto out;
   if(EOF == fputc(':', ctx->fp))
     goto out;
-  curl_free(enc);
+  tool_safefree(enc);
   r = curlx_base64_encode((const char *)sdata, sdata_len, &enc, &enc_len);
   if(r)
     goto out;
@@ -179,7 +179,7 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr,
 out:
   if(r)
     warnf("Warning: error saving SSL session for '%s': %d", session_key, r);
-  curl_free(enc);
+  free(enc);
   return r;
 }