[compiler-rt] [win/asan] Improve SharedReAlloc with HEAP_REALLOC_IN_PLACE_ONLY. (PR #132558)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 10:14:20 PDT 2025
================
@@ -322,6 +322,22 @@ void *SharedReAlloc(ReAllocFunction reallocFunc, SizeFunction heapSizeFunc,
}
}
+ if (dwFlags & HEAP_REALLOC_IN_PLACE_ONLY) {
+ size_t old_usable_size = asan_malloc_usable_size(lpMem, pc, bp);
+ if (dwBytes == old_usable_size) {
+ // Nothing to change, return the current pointer.
+ return lpMem;
+ } else if (dwBytes >= old_usable_size) {
+ // Growing with HEAP_REALLOC_IN_PLACE_ONLY is not supported.
+ return nullptr;
+ } else {
+ // Shrinking with HEAP_REALLOC_IN_PLACE_ONLY is not yet supported.
+ // For now return the current pointer and
+ // leave the allocation size as it is.
+ return lpMem;
+ }
+ }
----------------
thurstond wrote:
What if this were all replaced with `return nullptr;`'? Would that provide stronger protection, while still staying spec-compliant?
https://github.com/llvm/llvm-project/pull/132558
More information about the llvm-commits
mailing list