From bfc00bc7f28b54461eff53edc1802b0f89575a4a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 7 Nov 2024 11:57:37 +1030 Subject: [PATCH] lightningd: avoid false memleak positive with rpc_command_hook. On `dev-memleak`, if someone is using rpc_command_hook, we'll call it when the hook returns. But it will see these contexts as a leak. So attach them to tmpctx (which is excluded from leak detection). Signed-off-by: Rusty Russell --- lightningd/plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 3e5f6f291187..9dcb312484b1 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -615,7 +615,7 @@ static void mark_plugin_destroyed(const struct plugin *unused, static struct plugin_destroyed * plugin_detect_destruction(const struct plugin *plugin) { - struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed); + struct plugin_destroyed *pd = notleak(tal(NULL, struct plugin_destroyed)); pd->plugin = plugin; tal_add_destructor2(plugin, mark_plugin_destroyed, pd); return pd; @@ -655,7 +655,7 @@ static void plugin_response_handle(struct plugin *plugin, /* Request callback often frees request: if not, we do. */ - ctx = tal(NULL, char); + ctx = tal(tmpctx, char); tal_steal(ctx, request); /* Don't keep track of this request; we will terminate it */ tal_del_destructor2(request, destroy_request, plugin);