diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h index e495c56f03775..6e54c4852fbb6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h @@ -166,7 +166,7 @@ struct SizeClassAllocator32LocalCache { DCHECK_GT(c->count, 0); } void *res = c->batch[--c->count]; - PREFETCH(c->batch[c->count - 1]); + PREFETCH(c->batch[c->count > 0 ? c->count - 1 : 0]); stats_.Add(AllocatorStatAllocated, c->class_size); return res; }