diff options
author | Maria Matejka <mq@ucw.cz> | 2023-04-20 19:33:00 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-04-20 19:33:00 +0200 |
commit | 335409248ea932e93ce4361564b8e92d0b83b071 (patch) | |
tree | 0e0a85ce3ed7a0461a67504d1b6216e5f767611c /lib/mempool.c | |
parent | 9e44ace3928a19560058dc713fcbff3a8bad3b3c (diff) |
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.
Diffstat (limited to 'lib/mempool.c')
-rw-r--r-- | lib/mempool.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/mempool.c b/lib/mempool.c index 7c306e99..9d4404f7 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)) |