From 9aa2e4f5c41c76ea8d7941cfa73c8cd4df45cdf6 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 29 Jan 2013 08:19:11 +0000 Subject: [ASan] fix deallocation hook in allocator2: according to specification, dealloc hook should be called before deallocating memory llvm-svn: 173778 --- compiler-rt/lib/asan/asan_allocator2.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc index a77b92c83bf..15bdb83141f 100644 --- a/compiler-rt/lib/asan/asan_allocator2.cc +++ b/compiler-rt/lib/asan/asan_allocator2.cc @@ -419,6 +419,7 @@ static void *Allocate(uptr size, uptr alignment, StackTrace *stack, static void Deallocate(void *ptr, StackTrace *stack, AllocType alloc_type) { uptr p = reinterpret_cast(ptr); if (p == 0) return; + ASAN_FREE_HOOK(ptr); uptr chunk_beg = p - kChunkHeaderSize; AsanChunk *m = reinterpret_cast(chunk_beg); @@ -468,8 +469,6 @@ static void Deallocate(void *ptr, StackTrace *stack, AllocType alloc_type) { quarantine.Put(&fallback_quarantine_cache, QuarantineCallback(ac), m, m->UsedSize()); } - - ASAN_FREE_HOOK(ptr); } static void *Reallocate(void *old_ptr, uptr new_size, StackTrace *stack) { -- cgit v1.2.3