[compiler-rt] [lsan] Fix free(NULL) interception during initialization (PR #106912)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 1 09:28:01 PDT 2024
https://github.com/tmiasko created https://github.com/llvm/llvm-project/pull/106912
Previously an attempt to free a null pointer during initialization would fail on ENSURE_LSAN_INITED assertion (since a null pointer is not owned by DlsymAlloc).
>From ab1444f432d3a809237f3b55ce34e900ae0aa243 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= <tomasz.miasko at gmail.com>
Date: Sun, 1 Sep 2024 15:56:34 +0000
Subject: [PATCH] [lsan] Fix free(NULL) interception during initialization
Previously an attempt to free a null pointer during initialization would
fail on ENSURE_LSAN_INITED assertion (since a null pointer is not owned
by DlsymAlloc).
---
compiler-rt/lib/lsan/lsan_interceptors.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index b569c337e97641..db27be7d06995f 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -77,6 +77,8 @@ INTERCEPTOR(void*, malloc, uptr size) {
}
INTERCEPTOR(void, free, void *p) {
+ if (!p)
+ return;
if (DlsymAlloc::PointerIsMine(p))
return DlsymAlloc::Free(p);
ENSURE_LSAN_INITED;
More information about the llvm-commits
mailing list