lightningd: fix crash when old openingd still around.

We weren't killing it.  Eventually it would die, and peer_owner_finished()
would access subd->peer->owner, but that peer was freed already.

Closes: #261
Reported-by: Christian Decker <decker.christian@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-09-06 12:10:04 +09:30
committed by Christian Decker
parent 5889ad5fc4
commit b19a4516d4
2 changed files with 36 additions and 1 deletions

View File

@@ -454,6 +454,7 @@ static bool peer_reconnected(struct lightningd *ld,
int fd,
const struct crypto_state *cs)
{
struct subd *subd;
struct peer *peer = peer_by_id(ld, id);
if (!peer)
return false;
@@ -495,8 +496,9 @@ static bool peer_reconnected(struct lightningd *ld,
case OPENINGD:
/* Kill off openingd, forget old peer. */
subd = peer->owner;
peer->owner = NULL; /* We'll free it ourselves */
tal_free(peer->owner);
tal_free(subd);
tal_free(peer);
/* A fresh start. */