Skip to content

Commit b8a0b70

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
1 parent 8260528 commit b8a0b70

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ struct SizeClassAllocator32LocalCache {
166166
DCHECK_GT(c->count, 0);
167167
}
168168
void *res = c->batch[--c->count];
169-
PREFETCH(c->batch[c->count - 1]);
169+
// 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));
170173
stats_.Add(AllocatorStatAllocated, c->class_size);
171174
return res;
172175
}

0 commit comments

Comments
 (0)