From: Stefan Eissing Date: Mon, 1 Dec 2025 13:05:39 +0000 (+0100) Subject: memdebug: log before free X-Git-Tag: rc-8_18_0-1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1b85bc49c5dd0e2c2eaf06027b5520152317f62;p=thirdparty%2Fcurl.git memdebug: log before free 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 --- diff --git a/lib/memdebug.c b/lib/memdebug.c index 1dda6d785c..b6c2d854c3 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -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,