diff --git a/lightningd/channel.c b/lightningd/channel.c index 0c158b2cc..2b19df278 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -326,11 +326,13 @@ void channel_set_billboard(struct channel *channel, bool perm, const char *str) p = &channel->billboard.permanent[channel->state]; else p = &channel->billboard.transient; - tal_free(*p); + *p = tal_free(*p); - *p = tal_fmt(channel, "%s:%s", channel_state_name(channel), str); - if (taken(str)) - tal_free(str); + if (str) { + *p = tal_fmt(channel, "%s:%s", channel_state_name(channel), str); + if (taken(str)) + tal_free(str); + } } void channel_fail_transient(struct channel *channel, const char *fmt, ...) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index c8bf611fc..d145fed07 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -490,8 +490,9 @@ static void opening_channel_set_billboard(struct uncommitted_channel *uc, bool perm UNUSED, const char *happenings TAKES) { - tal_free(uc->transient_billboard); - uc->transient_billboard = tal_strdup(uc, happenings); + uc->transient_billboard = tal_free(uc->transient_billboard); + if (happenings) + uc->transient_billboard = tal_strdup(uc, happenings); } static void destroy_uncommitted_channel(struct uncommitted_channel *uc) diff --git a/lightningd/subd.c b/lightningd/subd.c index 7f3c0dc73..69e0a71e8 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -585,6 +585,8 @@ static void destroy_subd(struct subd *sd) struct db *db = sd->ld->wallet->db; bool outer_transaction; + /* Clear any transient messages in billboard */ + sd->billboardcb(channel, false, NULL); sd->channel = NULL; /* We can be freed both inside msg handling, or spontaneously. */ @@ -695,6 +697,9 @@ static struct subd *new_subd(struct lightningd *ld, log_debug(sd->log, "pid %u, msgfd %i", sd->pid, msg_fd); + /* Clear any old transient message. */ + if (billboardcb) + billboardcb(sd->channel, false, NULL); return sd; }