diff options
author | Alexander Potapenko <glider@google.com> | 2012-08-06 12:24:39 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2012-08-06 12:24:39 +0000 |
commit | 8f6dd3537cd42d60f70465ac13ae6841f0af2ac2 (patch) | |
tree | 768cad84fa5e41414b5de1a07b5f96dc486bc32a /compiler-rt | |
parent | ef3f5fe6bdcf7780b168bf2a1ddf08986fe7d0da (diff) | |
download | bcm5719-llvm-8f6dd3537cd42d60f70465ac13ae6841f0af2ac2.tar.gz bcm5719-llvm-8f6dd3537cd42d60f70465ac13ae6841f0af2ac2.zip |
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
llvm-svn: 161320
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator.cc | 9 |
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 { |