[compiler-rt] [scudo] Add hooks to mark the range of realloc (PR #73883)
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 18:15:20 PST 2023
================
@@ -27,6 +27,51 @@ static void reportDeallocation(void *ptr) {
if (__scudo_deallocate_hook)
__scudo_deallocate_hook(ptr);
}
+static void reportReallocBegin(void *old_ptr) {
+ if (SCUDO_ENABLE_HOOKS)
+ if (__scudo_realloc_begin_hook)
+ __scudo_realloc_begin_hook(old_ptr);
+}
+static void reportReallocEnd(void *old_ptr) {
+ if (SCUDO_ENABLE_HOOKS)
+ if (__scudo_realloc_end_hook)
+ __scudo_realloc_end_hook(old_ptr);
+}
+
+static void *reallocImpl(void *ptr, size_t size) {
+ if (!ptr) {
+ void *Ptr = SCUDO_ALLOCATOR.allocate(size, scudo::Chunk::Origin::Malloc,
+ SCUDO_MALLOC_ALIGNMENT);
+ reportAllocation(Ptr, size);
----------------
cferris1000 wrote:
I know this isn't your problem, but if Ptr is nullptr, should the reportAllocation hook be called? This wouldn't normally happen, but if you are working with user data setting the size, I can see cases where an invalid size is passed in and fails to allocate.
https://github.com/llvm/llvm-project/pull/73883
More information about the llvm-commits
mailing list