summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_allocator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan/asan_allocator.cc')
-rw-r--r--compiler-rt/lib/asan/asan_allocator.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc
index 352cce00fbe..b9c194233cf 100644
--- a/compiler-rt/lib/asan/asan_allocator.cc
+++ b/compiler-rt/lib/asan/asan_allocator.cc
@@ -377,10 +377,11 @@ class MallocInfo {
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 {
OpenPOWER on IntegriCloud