]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
memdebug: log before free
authorStefan Eissing <stefan@eissing.org>
Mon, 1 Dec 2025 13:05:39 +0000 (14:05 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 1 Dec 2025 13:12:59 +0000 (14:12 +0100)
add the debug log before freeing the memory, otherwise another thread
might allocate and log it before the free is logged.

Follow-up to a7bebd8502914f1652f423
Closes #19787

lib/memdebug.c

index 1dda6d785cca2122aa3f34bfc34695564da5f259..b6c2d854c33ee36d41fe179531d929ab142c601c 100644 (file)
@@ -337,6 +337,9 @@ void curl_dbg_free(void *ptr, int line, const char *source)
   if(ptr) {
     struct memdebug *mem;
 
+  if(source)
+    curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
+
 #ifdef __INTEL_COMPILER
 #  pragma warning(push)
 #  pragma warning(disable:1684)
@@ -352,9 +355,6 @@ void curl_dbg_free(void *ptr, int line, const char *source)
     /* free for real */
     (Curl_cfree)(mem);
   }
-
-  if(source && ptr)
-    curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
 }
 
 curl_socket_t curl_dbg_socket(int domain, int type, int protocol,