[compiler-rt] [scudo] Add primary option to zero block on dealloc. (PR #142394)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 11:09:33 PST 2025
================
@@ -1345,6 +1352,19 @@ class Allocator {
BlockBegin = retagBlock(Options, TaggedPtr, Ptr, Header, Size, true);
}
+#ifdef SCUDO_FUCHSIA
+ if (AllocatorConfig::getEnableZeroOnDealloc()) {
+ // Clearing the header and is incompatible with quarantine and tagging.
+ // Hence, it is fine to implement it only when quanrantine is bypassed.
+ DCHECK(!useMemoryTagging<AllocatorConfig>(Options));
+ uptr length = reinterpret_cast<uptr>(Ptr) + Size -
+ reinterpret_cast<uptr>(BlockBegin);
+ if (length <= ZeroOnDeallocMaxSize) {
+ memset(BlockBegin, 0, length);
+ }
----------------
ChiaHungDuan wrote:
nit: simple single statement, https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
https://github.com/llvm/llvm-project/pull/142394
More information about the llvm-commits
mailing list