Skip to content

Commit 5275563

Browse files
committed
fix C++ sized deallocation check false positive
This is a compatibility issue triggered when both slab canaries and the C++ allocator overloads providing sized deallocation checks are enabled. The boundary where slab allocations are turned into large allocations due to not having room for the canary in the largest slab allocation size class triggers a false positive in the sized deallocation check.
1 parent e9d9f70 commit 5275563

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

h_malloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,9 +1552,11 @@ EXPORT void h_free_sized(void *p, size_t expected_size) {
15521552
return;
15531553
}
15541554

1555+
expected_size = adjust_size_for_canaries(expected_size);
1556+
15551557
if (p < get_slab_region_end() && p >= ro.slab_region_start) {
15561558
thread_unseal_metadata();
1557-
expected_size = get_size_info(adjust_size_for_canaries(expected_size)).size;
1559+
expected_size = get_size_info(expected_size).size;
15581560
deallocate_small(p, &expected_size);
15591561
thread_seal_metadata();
15601562
return;

0 commit comments

Comments
 (0)