json_getroute: don't leak.

Allocate the route off the current command, not dstate.  And in the
case where the route is somehow not via a peer, don't leak memory.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-11-04 11:17:04 +10:30
parent a902193874
commit b40c4ae766
3 changed files with 15 additions and 12 deletions

View File

@@ -67,7 +67,8 @@ struct node_connection *add_connection(struct lightningd_state *dstate,
void remove_connection(struct lightningd_state *dstate,
const struct pubkey *src, const struct pubkey *dst);
struct peer *find_route(struct lightningd_state *dstate,
struct peer *find_route(const tal_t *ctx,
struct lightningd_state *dstate,
const struct pubkey *to,
u64 msatoshi,
double riskfactor,