extend the PTRDIFF_MAX size check to mremap
This removes another way to obtain objects larger than PTRDIFF_MAX. The only known remaining hole is now jemalloc's merging of virtual memory spans. Technically this could be wrapped in an __LP64__ ifndef since it can't occur on 64-bit due to the 1:1 split. It doesn't really matter either way. Change-Id: Iab2af242b775bc98a59421994d87aca0433215bd
This commit is contained in:
@@ -219,3 +219,15 @@ TEST(sys_mman, posix_madvise_POSIX_MADV_DONTNEED) {
|
||||
TEST(sys_mman, mremap) {
|
||||
ASSERT_EQ(MAP_FAILED, mremap(nullptr, 0, 0, 0));
|
||||
}
|
||||
|
||||
const size_t huge = PTRDIFF_MAX + 1;
|
||||
|
||||
TEST(sys_mman, mmap_PTRDIFF_MAX) {
|
||||
ASSERT_EQ(MAP_FAILED, mmap(nullptr, huge, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
|
||||
}
|
||||
|
||||
TEST(sys_mman, mremap_PTRDIFF_MAX) {
|
||||
void* map = mmap(nullptr, PAGE_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
ASSERT_NE(MAP_FAILED, map);
|
||||
ASSERT_EQ(MAP_FAILED, mremap(map, PAGE_SIZE, huge, MREMAP_MAYMOVE));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user