Skip to content

Commit 21c85d9

Browse files
author
Advenam Tacet
committed
[ASan][ADT] Don't scribble with ASan
AddressSanitizer (ASAN) disables scribbling to prevent overwriting poisoned objects. Needed by llvm#79049
1 parent cc2c8ab commit 21c85d9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,10 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
317317
// Clear the old callback and inline flag to get back to as-if-null.
318318
RHS.CallbackAndInlineFlag = {};
319319

320-
#ifndef NDEBUG
321-
// In debug builds, we also scribble across the rest of the storage.
320+
#if !defined(NDEBUG) && !(defined(ADDRESS_SANITIZER) || defined(__SANITIZE_ADDRESS__))
321+
// In debug builds without ASan, we also scribble across the rest of the storage.
322+
// AddressSanitizer (ASAN) disables scribbling to prevent overwriting poisoned objects
323+
// (e.g., annotated short strings).
322324
memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
323325
#endif
324326
}

0 commit comments

Comments
 (0)