check for double free slightly earlier
parent
0a79e82474
commit
2d168b0516
7
malloc.c
7
malloc.c
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue