From 2632cddfe46bc35f76796ff1c1154b82a6870cef Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 5 Jul 2022 12:10:41 +0200 Subject: [PATCH] pay: Fix a memory leak when retrying getroute --- plugins/libplugin-pay.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index e27305fa9..b44716d7a 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -809,6 +809,10 @@ static struct command_result *payment_getroute(struct payment *p) const char *errstr; struct gossmap *gossmap; + /* If we retry the getroute call we might already have a route, so + * free an eventual stale route. */ + p->route = tal_free(p->route); + gossmap = get_gossmap(p->plugin); dst = gossmap_find_node(gossmap, p->getroute->destination);