diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-03-22 13:35:40 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2016-03-23 02:21:42 +0100 |
commit | 665b8e5283df4f64eb44d8fb434489be1474b5d4 (patch) | |
tree | ef39499819c6c674a75647551d4f1fec2f9098f2 /lib/resource.c | |
parent | 39a6b19d6d7e420805bd75783b77bf442745bccb (diff) |
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().
Diffstat (limited to 'lib/resource.c')
-rw-r--r-- | lib/resource.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/resource.c b/lib/resource.c index 64f9a39c..68718dfb 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -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; - - if (m) - { - ob = SKIP_BACK(struct mblock, data, m); - if (ob->r.n.next) - rem_node(&ob->r.n); - } + struct mblock *b = SKIP_BACK(struct mblock, data, m); - 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; |