diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2016-04-14 09:52:33 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2016-04-14 09:52:33 +0000 |
commit | a7de697ae6a5bf69231e2e0504fb4b0c1e95a3b5 (patch) | |
tree | cab2f9e2f8385bfeb068ba3f2964dd92a42b4120 | |
parent | 9d64f7264035d8d573abed95a15a07cb31796063 (diff) | |
download | bcm5719-llvm-a7de697ae6a5bf69231e2e0504fb4b0c1e95a3b5.tar.gz bcm5719-llvm-a7de697ae6a5bf69231e2e0504fb4b0c1e95a3b5.zip |
asan: fix out-of-bounds access in quarantine
llvm-svn: 266288
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h b/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h index 9e0bf2d18fe..095c8065417 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h @@ -101,10 +101,12 @@ class Quarantine { void NOINLINE DoRecycle(Cache *c, Callback cb) { while (QuarantineBatch *b = c->DequeueBatch()) { const uptr kPrefetch = 16; + COMPILER_CHECK(kPrefetch <= ARRAY_SIZE(b->batch)); for (uptr i = 0; i < kPrefetch; i++) PREFETCH(b->batch[i]); - for (uptr i = 0; i < b->count; i++) { - PREFETCH(b->batch[i + kPrefetch]); + for (uptr i = 0, count = b->count; i < count; i++) { + if (i + kPrefetch < count) + PREFETCH(b->batch[i + kPrefetch]); cb.Recycle((Node*)b->batch[i]); } cb.Deallocate(b); |