Commit 3e9865fc authored by Igor Sugak's avatar Igor Sugak Committed by Facebook GitHub Bot

fix nullptr-with-nonzero-offset UB in CacheLocality.h

Reviewed By: yfeldblum, andriigrynenko

Differential Revision: D29914176

fbshipit-source-id: 981b75acec24391822ace833d4265fed0c5d0cb3
parent c22c915d
......@@ -382,20 +382,21 @@ class SimpleAllocator {
return mem;
}
// Bump-ptr allocation.
if (intptr_t(mem_) % 128 == 0) {
// Avoid allocating pointers that may look like malloc
// pointers.
mem_ += std::min(sz_, max_align_v);
}
if (mem_ && (mem_ + sz_ <= end_)) {
auto mem = mem_;
mem_ += sz_;
if (mem_) {
// Bump-ptr allocation.
if (intptr_t(mem_) % 128 == 0) {
// Avoid allocating pointers that may look like malloc
// pointers.
mem_ += std::min(sz_, max_align_v);
}
if (mem_ + sz_ <= end_) {
auto mem = mem_;
mem_ += sz_;
assert(intptr_t(mem) % 128 != 0);
return mem;
assert(intptr_t(mem) % 128 != 0);
return mem;
}
}
return allocateHard();
}
void deallocate(void* mem) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment