Browse Source

log: fix ltmp crash.

When we clear and recreate ltmp, we attach it to whatever logbook it's on.
This, of course, is fraught, since it may be freed.

We could make it NULL-parented, but that makes YA special-case to free
when we exit (we try to keep valgrind happy by freeing everything).  So
since the first log_book is the permanent one attached to lightningd,
just keep that parent when we re-build it after use.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
4aeebe88f2
  1. 5
      lightningd/log.c

5
lightningd/log.c

@ -137,7 +137,7 @@ struct log_book *new_log_book(size_t max_mem,
lr->init_time = time_now();
list_head_init(&lr->log);
/* In case ltmp not initialized, do so now. */
/* In case ltmp not initialized, do so now (parent is lightningd log) */
if (!ltmp)
ltmp = notleak(tal(lr, char));
@ -228,8 +228,9 @@ static void add_entry(struct log *log, struct log_entry *l)
/* Free up temporaries now if any */
if (tal_first(ltmp)) {
void *parent = tal_parent(ltmp);
tal_free(ltmp);
ltmp = notleak(tal(log->lr, char));
ltmp = notleak(tal(parent, char));
}
}

Loading…
Cancel
Save