From: Maria Matejka Date: Thu, 20 Apr 2023 17:33:00 +0000 (+0200) Subject: Linpool: Fix lp_restore() X-Git-Tag: v2.13~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=335409248ea932e93ce4361564b8e92d0b83b071;p=thirdparty%2Fbird.git Linpool: Fix lp_restore() When lp_save() is called on an empty linpool, then some allocation is done, then lp_restore() is called, the linpool is restored but the used chunks are inaccessible. Fix it. --- diff --git a/lib/mempool.c b/lib/mempool.c index 7c306e991..9d4404f7c 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -240,9 +240,9 @@ lp_restore(linpool *m, lp_state *p) struct lp_chunk *c; /* Move ptr to the saved pos and free all newer large chunks */ - m->current = c = p->current; - m->ptr = p->ptr; - m->end = c ? c->data + LP_DATA_SIZE : NULL; + m->current = c = p->current ?: m->first; + m->ptr = p->ptr ?: (c ? c->data : NULL); + m->end = c ? (c->data + LP_DATA_SIZE) : NULL; m->total_large = p->total_large; while ((c = m->first_large) && (c != p->large))