[compiler-rt] [scudo] Add an option to zero memory on deallocation. (PR #142394)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 08:09:49 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);
+ }
----------------
piwicode wrote:
Done.
https://github.com/llvm/llvm-project/pull/142394
More information about the llvm-commits
mailing list