We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8260528 commit b8a0b70Copy full SHA for b8a0b70
compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h
@@ -166,7 +166,10 @@ struct SizeClassAllocator32LocalCache {
166
DCHECK_GT(c->count, 0);
167
}
168
void *res = c->batch[--c->count];
169
- PREFETCH(c->batch[c->count - 1]);
+ // By not doing pointer arithmetic, we avoid the OOB if c->count = 0.
170
+ // We just prefetch the previous member of the PerClass struct, which
171
+ // doesn't do harm.
172
+ PREFETCH(reinterpret_cast<uptr>(c->batch) + sizeof(c->batch[0])* (c->count - 1));
173
stats_.Add(AllocatorStatAllocated, c->class_size);
174
return res;
175
0 commit comments