From 8f7d1e9a41bb0182166aac6a8d4d8b00f60ed032 Mon Sep 17 00:00:00 2001 From: Daan Date: Fri, 29 Mar 2024 11:17:21 -0700 Subject: [PATCH] fix free in realpath when using ASAN --- src/alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/alloc.c b/src/alloc.c index 2e03eca0..32175b0c 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -396,7 +396,8 @@ char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) char* rname = realpath(fname, NULL); if (rname == NULL) return NULL; char* result = mi_heap_strdup(heap, rname); - free(rname); // use regular free! (which may be redirected to our free but that's ok) + mi_cfree(rname); // use checked free (which may be redirected to our free but that's ok) + // note: with ASAN realpath is intercepted and mi_cfree may leak the returned pointer :-( return result; } /*