[compiler-rt] r173778 - [ASan] fix deallocation hook in allocator2: according to specification, dealloc hook should be called before deallocating memory

Alexey Samsonov samsonov at google.com
Tue Jan 29 00:19:11 PST 2013


Author: samsonov
Date: Tue Jan 29 02:19:11 2013
New Revision: 173778

URL: http://llvm.org/viewvc/llvm-project?rev=173778&view=rev
Log:
[ASan] fix deallocation hook in allocator2: according to specification, dealloc hook should be called before deallocating memory

Modified:
    compiler-rt/trunk/lib/asan/asan_allocator2.cc

Modified: compiler-rt/trunk/lib/asan/asan_allocator2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator2.cc?rev=173778&r1=173777&r2=173778&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator2.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator2.cc Tue Jan 29 02:19:11 2013
@@ -419,6 +419,7 @@ static void *Allocate(uptr size, uptr al
 static void Deallocate(void *ptr, StackTrace *stack, AllocType alloc_type) {
   uptr p = reinterpret_cast<uptr>(ptr);
   if (p == 0) return;
+  ASAN_FREE_HOOK(ptr);
   uptr chunk_beg = p - kChunkHeaderSize;
   AsanChunk *m = reinterpret_cast<AsanChunk *>(chunk_beg);
 
@@ -468,8 +469,6 @@ static void Deallocate(void *ptr, StackT
     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) {





More information about the llvm-commits mailing list