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

@@ -241,7 +241,8 @@ static void json_getroute(struct command *cmd,
return;
}
peer = find_route(cmd->dstate, &id, msatoshi, riskfactor, &fee, &route);
peer = find_route(cmd, cmd->dstate, &id, msatoshi, riskfactor,
&fee, &route);
if (!peer) {
command_fail(cmd, "no route found");
return;