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 a7bebd8502
Closes #19787
This commit is contained in:
Stefan Eissing 2025-12-01 14:05:39 +01:00 committed by Daniel Stenberg
parent a7bebd8502
commit d1b85bc49c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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,