forked from OSchip/llvm-project
[sanitizer] Fix boundary condition in LargeMmapAllocator::GetBlockBegin. Patch by Sergey Matveev
llvm-svn: 179007
This commit is contained in:
parent
85c19f5a73
commit
e6459977b8
|
@ -1014,7 +1014,7 @@ class LargeMmapAllocator {
|
|||
CHECK_GE(nearest_chunk, h->map_beg);
|
||||
CHECK_LT(nearest_chunk, h->map_beg + h->map_size);
|
||||
CHECK_LE(nearest_chunk, p);
|
||||
if (h->map_beg + h->map_size < p)
|
||||
if (h->map_beg + h->map_size <= p)
|
||||
return 0;
|
||||
return GetUser(h);
|
||||
}
|
||||
|
|
|
@ -337,6 +337,14 @@ TEST(SanitizerCommon, LargeMmapAllocator) {
|
|||
a.Deallocate(&stats, allocated[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test for boundary condition in GetBlockBegin().
|
||||
uptr page_size = GetPageSizeCached();
|
||||
char *p = (char *)a.Allocate(&stats, page_size, 1);
|
||||
CHECK_EQ(p, a.GetBlockBegin(p));
|
||||
CHECK_EQ(p, (char *)a.GetBlockBegin(p + page_size - 1));
|
||||
CHECK_NE(p, (char *)a.GetBlockBegin(p + page_size));
|
||||
a.Deallocate(&stats, p);
|
||||
}
|
||||
|
||||
template
|
||||
|
@ -629,7 +637,6 @@ TEST(SanitizerCommon, SizeClassAllocator32Iteration) {
|
|||
TestSizeClassAllocatorIteration<Allocator32Compact>();
|
||||
}
|
||||
|
||||
|
||||
TEST(SanitizerCommon, LargeMmapAllocatorIteration) {
|
||||
LargeMmapAllocator<> a;
|
||||
a.Init();
|
||||
|
|
Loading…
Reference in New Issue