@@ -277,7 +277,8 @@ static void enqueue_peer_msg(struct peer *peer, const u8 *msg TAKES)
277
277
/* Should not return */
278
278
abort ();
279
279
case DEV_DISCONNECT_DROPPKT :
280
- tal_free (msg );
280
+ if (taken (msg ))
281
+ tal_free (msg );
281
282
/* Fail next time we try to do something. */
282
283
dev_sabotage_fd (PEER_FD );
283
284
return ;
@@ -1834,7 +1835,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
1834
1835
1835
1836
static bool channeld_send_reply (struct crypto_state * cs UNUSED ,
1836
1837
int peer_fd UNUSED ,
1837
- const u8 * msg UNUSED ,
1838
+ const u8 * msg ,
1838
1839
struct peer * peer )
1839
1840
{
1840
1841
enqueue_peer_msg (peer , msg );
@@ -2625,15 +2626,15 @@ int main(int argc, char *argv[])
2625
2626
}
2626
2627
2627
2628
if (FD_ISSET (MASTER_FD , & rfds )) {
2628
- msg = wire_sync_read (peer , MASTER_FD );
2629
+ msg = wire_sync_read (tmpctx , MASTER_FD );
2629
2630
2630
2631
if (!msg )
2631
2632
status_failed (STATUS_FAIL_MASTER_IO ,
2632
2633
"Can't read command: %s" ,
2633
2634
strerror (errno ));
2634
2635
req_in (peer , msg );
2635
2636
} else if (FD_ISSET (GOSSIP_FD , & rfds )) {
2636
- msg = wire_sync_read (peer , GOSSIP_FD );
2637
+ msg = wire_sync_read (tmpctx , GOSSIP_FD );
2637
2638
/* Gossipd hangs up on us to kill us when a new
2638
2639
* connection comes in. */
2639
2640
if (!msg )
@@ -2644,11 +2645,11 @@ int main(int argc, char *argv[])
2644
2645
} else if (FD_ISSET (PEER_FD , & rfds )) {
2645
2646
/* This could take forever, but who cares? */
2646
2647
msg = channeld_read_peer_msg (peer );
2647
- if (msg )
2648
+ if (msg ) {
2648
2649
peer_in (peer , msg );
2649
- } else
2650
- msg = NULL ;
2651
- tal_free ( msg );
2650
+ tal_free ( msg );
2651
+ }
2652
+ }
2652
2653
}
2653
2654
2654
2655
/* We only exit when shutdown is complete. */
0 commit comments