mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Birdlib: Do cleanups after remove/free
To avoid byzantine behavior in case of some errors, linked lists are cleared after rem_node() and resource headers are cleared after rfree().
This commit is contained in:
@@ -163,6 +163,7 @@ rfree(void *res)
|
||||
if (r->n.next)
|
||||
rem_node(&r->n);
|
||||
r->class->free(r);
|
||||
r->class = NULL;
|
||||
xfree(r);
|
||||
}
|
||||
|
||||
@@ -383,16 +384,9 @@ mb_allocz(pool *p, unsigned size)
|
||||
void *
|
||||
mb_realloc(void *m, unsigned size)
|
||||
{
|
||||
struct mblock *ob = NULL;
|
||||
struct mblock *b = SKIP_BACK(struct mblock, data, m);
|
||||
|
||||
if (m)
|
||||
{
|
||||
ob = SKIP_BACK(struct mblock, data, m);
|
||||
if (ob->r.n.next)
|
||||
rem_node(&ob->r.n);
|
||||
}
|
||||
|
||||
struct mblock *b = xrealloc(ob, sizeof(struct mblock) + size);
|
||||
b = xrealloc(b, sizeof(struct mblock) + size);
|
||||
replace_node(&b->r.n, &b->r.n);
|
||||
b->size = size;
|
||||
return b->data;
|
||||
|
Reference in New Issue
Block a user