[llvm-commits] [compiler-rt] r161320 - /compiler-rt/trunk/lib/asan/asan_allocator.cc

Alexander Potapenko glider at google.com
Mon Aug 6 05:24:39 PDT 2012


Author: glider
Date: Mon Aug  6 07:24:39 2012
New Revision: 161320

URL: http://llvm.org/viewvc/llvm-project?rev=161320&view=rev
Log:
AllocationSize(ptr) should check that |ptr| actually points to the beginning of the chunk it belongs to.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=86


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

Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=161320&r1=161319&r2=161320&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Mon Aug  6 07:24:39 2012
@@ -377,10 +377,11 @@
     if (!ptr) return 0;
     ScopedLock lock(&mu_);
 
-    // first, check if this is our memory
-    PageGroup *g = FindPageGroupUnlocked(ptr);
-    if (!g) return 0;
-    AsanChunk *m = PtrToChunk(ptr);
+    // Make sure this is our chunk and |ptr| actually points to the beginning
+    // of the allocated memory.
+    AsanChunk *m = FindChunkByAddr(ptr);
+    if (!m || m->Beg() != ptr) return 0;
+
     if (m->chunk_state == CHUNK_ALLOCATED) {
       return m->used_size;
     } else {





More information about the llvm-commits mailing list