check canary before zeroing as an optimization
parent
6f30211da8
commit
00915521a3
8
malloc.c
8
malloc.c
|
@ -512,10 +512,6 @@ static inline void deallocate_small(void *p, const size_t *expected_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_zero_size) {
|
if (!is_zero_size) {
|
||||||
if (ZERO_ON_FREE) {
|
|
||||||
memset(p, 0, size - canary_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canary_size) {
|
if (canary_size) {
|
||||||
u64 canary_value;
|
u64 canary_value;
|
||||||
memcpy(&canary_value, (char *)p + size - canary_size, canary_size);
|
memcpy(&canary_value, (char *)p + size - canary_size, canary_size);
|
||||||
|
@ -523,6 +519,10 @@ static inline void deallocate_small(void *p, const size_t *expected_size) {
|
||||||
fatal_error("canary corrupted");
|
fatal_error("canary corrupted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ZERO_ON_FREE) {
|
||||||
|
memset(p, 0, size - canary_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_free_slots(slots, metadata)) {
|
if (!has_free_slots(slots, metadata)) {
|
||||||
|
|
Loading…
Reference in New Issue