[compiler-rt] [sanitizer] add null check (PR #105612)

Wu Yingcong via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 21:40:28 PDT 2024


https://github.com/yingcong-wu created https://github.com/llvm/llvm-project/pull/105612

`dlsym()` could return nullptr, we should check the return value before using it.

>From d1fb2fb5047c50d3636230b52b298a674150a681 Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong.wu at intel.com>
Date: Wed, 21 Aug 2024 21:39:13 -0700
Subject: [PATCH] add null check

---
 compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index c3c717bbdbe4c9..f9b0f0e198bf16 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -235,6 +235,7 @@ void InitTlsSize() {
 #    if defined(__aarch64__) || defined(__x86_64__) || \
         defined(__powerpc64__) || defined(__loongarch__)
   void *get_tls_static_info = dlsym(RTLD_NEXT, "_dl_get_tls_static_info");
+  CHECK_NE(get_tls_static_info, nullptr);
   size_t tls_align;
   ((void (*)(size_t *, size_t *))get_tls_static_info)(&g_tls_size, &tls_align);
 #    endif



More information about the llvm-commits mailing list