Skip to content

Commit 36c9bce

Browse files
committed
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 <[email protected]>
1 parent d62abec commit 36c9bce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightningd/plugin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static void mark_plugin_destroyed(const struct plugin *unused,
615615
static struct plugin_destroyed *
616616
plugin_detect_destruction(const struct plugin *plugin)
617617
{
618-
struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed);
618+
struct plugin_destroyed *pd = notleak(tal(NULL, struct plugin_destroyed));
619619
pd->plugin = plugin;
620620
tal_add_destructor2(plugin, mark_plugin_destroyed, pd);
621621
return pd;
@@ -655,7 +655,7 @@ static void plugin_response_handle(struct plugin *plugin,
655655

656656

657657
/* Request callback often frees request: if not, we do. */
658-
ctx = tal(NULL, char);
658+
ctx = tal(tmpctx, char);
659659
tal_steal(ctx, request);
660660
/* Don't keep track of this request; we will terminate it */
661661
tal_del_destructor2(request, destroy_request, plugin);

0 commit comments

Comments
 (0)