Fix double free of message buffer.

Message buffer `why` is allocated in the `peer` context and also freed when peer is freed.
Only explicitly free the buffer when peer itself is not freed yet.
This commit is contained in:
Björge Dijkstra
2018-01-14 23:49:37 +01:00
committed by Rusty Russell
parent 3c0d2813a0
commit 44836ef509

View File

@@ -208,11 +208,11 @@ void peer_fail_permanent(struct peer *peer, const char *fmt, ...)
}
peer_set_owner(peer, NULL);
if (peer_persists(peer))
if (peer_persists(peer)) {
drop_to_chain(peer);
else
tal_free(why);
} else
free_peer(peer, why);
tal_free(why);
}
void peer_internal_error(struct peer *peer, const char *fmt, ...)