check canary before zeroing as an optimization

pull/65/head
Daniel Micay 2018-10-28 21:07:35 -04:00
parent 6f30211da8
commit 00915521a3
1 changed files with 4 additions and 4 deletions

View File

@ -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)) {