diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 6f2bbd936..89a23f7dc 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -106,6 +106,8 @@ void peer_fail_permanent(struct peer *peer, const u8 *msg) (int)tal_len(msg), (char *)msg); peer->error = towire_error(peer, &all_channels, msg); peer->owner = NULL; + if (taken(msg)) + tal_free(msg); if (peer_persists(peer)) drop_to_chain(peer); diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h index fd0ce361b..8175e73aa 100644 --- a/lightningd/peer_control.h +++ b/lightningd/peer_control.h @@ -150,7 +150,7 @@ void add_peer(struct lightningd *ld, u64 unique_id, /* Peer has failed, but try reconnected. */ PRINTF_FMT(2,3) void peer_fail_transient(struct peer *peer, const char *fmt,...); /* Peer has failed, give up on it. */ -void peer_fail_permanent(struct peer *peer, const u8 *msg); +void peer_fail_permanent(struct peer *peer, const u8 *msg TAKES); /* Permanent error, but due to internal problems, not peer. */ void peer_internal_error(struct peer *peer, const char *fmt, ...);