Skip to content

Commit

Permalink
lightningd: avoid false memleak positive with rpc_command_hook.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rustyrussell committed Nov 7, 2024
1 parent 5681c08 commit bfc00bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bfc00bc

Please sign in to comment.