From 8e18c338cd3274dd6507c90ed5b42a478baf29bb Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 12 Jan 2024 20:42:57 -0600 Subject: [PATCH] Guard no_sanitize attribute more carefully. --- src/engine/function.cpp | 4 +++- src/engine/hash.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/function.cpp b/src/engine/function.cpp index f2887c7648..d60727c421 100644 --- a/src/engine/function.cpp +++ b/src/engine/function.cpp @@ -286,10 +286,12 @@ struct _stack data = end; } - #ifdef __clang__ + #if defined(__clang__) && defined(__has_feature) + #if __has_feature(address_sanitizer) // This function calls not properly type-erased callbacks __attribute__((no_sanitize("undefined"))) #endif + #endif void done() { if ( cleanups_size > cleanups_t::size_type(0) ) diff --git a/src/engine/hash.cpp b/src/engine/hash.cpp index 4f2d8f114c..913dbb73e0 100644 --- a/src/engine/hash.cpp +++ b/src/engine/hash.cpp @@ -274,10 +274,12 @@ static void hashrehash( struct hash * hp ) } -#ifdef __clang__ +#if defined(__clang__) && defined(__has_feature) +#if __has_feature(address_sanitizer) // This function calls not properly type-erased callbacks __attribute__((no_sanitize("undefined"))) #endif +#endif void hashenumerate( struct hash * hp, void (* f)( void *, void * ), void * data ) {