0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-10-18 09:58:43 +00:00

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.
This commit is contained in:
Maria Matejka 2023-04-20 19:33:00 +02:00 committed by Ondrej Zajicek
parent 9e44ace392
commit 335409248e

View File

@ -240,9 +240,9 @@ lp_restore(linpool *m, lp_state *p)
struct lp_chunk *c; struct lp_chunk *c;
/* Move ptr to the saved pos and free all newer large chunks */ /* Move ptr to the saved pos and free all newer large chunks */
m->current = c = p->current; m->current = c = p->current ?: m->first;
m->ptr = p->ptr; m->ptr = p->ptr ?: (c ? c->data : NULL);
m->end = c ? c->data + LP_DATA_SIZE : NULL; m->end = c ? (c->data + LP_DATA_SIZE) : NULL;
m->total_large = p->total_large; m->total_large = p->total_large;
while ((c = m->first_large) && (c != p->large)) while ((c = m->first_large) && (c != p->large))