Skip to content

Commit 6936fad

Browse files
authored
[compiler-rt] [sanitizer] avoid UB in allocator (#126977)
1 parent 105b3a9 commit 6936fad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ struct SizeClassAllocator32LocalCache {
166166
DCHECK_GT(c->count, 0);
167167
}
168168
void *res = c->batch[--c->count];
169-
PREFETCH(c->batch[c->count - 1]);
169+
PREFETCH(c->batch[c->count > 0 ? c->count - 1 : 0]);
170170
stats_.Add(AllocatorStatAllocated, c->class_size);
171171
return res;
172172
}

0 commit comments

Comments
 (0)