check for double free slightly earlier

pull/50/head
Daniel Micay 2018-08-24 04:51:52 -04:00
parent 0a79e82474
commit 2d168b0516
1 changed files with 4 additions and 3 deletions

View File

@ -387,6 +387,10 @@ static void slab_free(void *p) {
fatal_error("invalid unaligned free"); fatal_error("invalid unaligned free");
} }
if (!get_slot(metadata, slot)) {
fatal_error("double free");
}
if (!has_free_slots(slots, metadata)) { if (!has_free_slots(slots, metadata)) {
metadata->next = c->partial_slabs; metadata->next = c->partial_slabs;
metadata->prev = NULL; metadata->prev = NULL;
@ -397,9 +401,6 @@ static void slab_free(void *p) {
c->partial_slabs = metadata; c->partial_slabs = metadata;
} }
if (!get_slot(metadata, slot)) {
fatal_error("double free");
}
clear_slot(metadata, slot); clear_slot(metadata, slot);
memset(p, 0, size); memset(p, 0, size);