check canary before zeroing as an optimization
This commit is contained in:
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 (ZERO_ON_FREE) {
|
||||
memset(p, 0, size - canary_size);
|
||||
}
|
||||
|
||||
if (canary_size) {
|
||||
u64 canary_value;
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
if (ZERO_ON_FREE) {
|
||||
memset(p, 0, size - canary_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_free_slots(slots, metadata)) {
|
||||
|
Loading…
Reference in New Issue
Block a user