diff options
| author | Kostya Serebryany <kcc@google.com> | 2013-03-11 09:43:12 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2013-03-11 09:43:12 +0000 |
| commit | 0f5c20b417c63627e12b3c503d4e9d17709682a2 (patch) | |
| tree | 9a8d3e331e3ac390c9d959c5708abf90fc1cb8bf /compiler-rt/lib/sanitizer_common/sanitizer_allocator.h | |
| parent | 1e02e73c30a272b0caa36537b11a4a0d2f5b0070 (diff) | |
| download | bcm5719-llvm-0f5c20b417c63627e12b3c503d4e9d17709682a2.tar.gz bcm5719-llvm-0f5c20b417c63627e12b3c503d4e9d17709682a2.zip | |
[sanitizer] make SizeClassAllocator64::GetBlockBegin more bullet proof (by Sergey Matveev)
llvm-svn: 176799
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_allocator.h')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_allocator.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h index e1f06f3b6ae..7d4554c6638 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h @@ -358,10 +358,12 @@ class SizeClassAllocator64 { void *GetBlockBegin(void *p) { uptr class_id = GetSizeClass(p); uptr size = SizeClassMap::Size(class_id); + if (!size) return 0; uptr chunk_idx = GetChunkIdx((uptr)p, size); uptr reg_beg = (uptr)p & ~(kRegionSize - 1); uptr beg = chunk_idx * size; uptr next_beg = beg + size; + if (class_id >= kNumClasses) return 0; RegionInfo *region = GetRegionInfo(class_id); if (region->mapped_user >= next_beg) return reinterpret_cast<void*>(reg_beg + beg); |

