From d80de68665f9c779e17a113bbe2be271c94bc92b Mon Sep 17 00:00:00 2001 From: Devyn Cairns Date: Sat, 27 Jul 2024 19:39:17 -0700 Subject: [PATCH] Clean up arguments added to stack after `CallDecl` engine call (#13469) # Description Just realized I hadn't been cleaning up the arguments added to the `Stack` after the `CallDecl` engine call was finished, so there could be a bit of a memory leak if a plugin made many calls during the duration of a single plugin call. This is a quick patch to that. I'm probably going to revise how this all works at some point soon because I think it is a bit of a pitfall. It would be good to make it much more difficult to make a mistake with it, perhaps with a guard like Ian did for the redirection stuff. # After Submitting - [ ] release with 0.96.1 --- crates/nu-plugin-engine/src/context.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/nu-plugin-engine/src/context.rs b/crates/nu-plugin-engine/src/context.rs index d9023cde35..160ce802b2 100644 --- a/crates/nu-plugin-engine/src/context.rs +++ b/crates/nu-plugin-engine/src/context.rs @@ -257,12 +257,9 @@ impl<'a> PluginExecutionContext for PluginExecutionCommandContext<'a> { } } - decl.run( - &self.engine_state, - stack, - &(&call_builder.finish()).into(), - input, - ) + call_builder.with(stack, |stack, call| { + decl.run(&self.engine_state, stack, call, input) + }) } fn boxed(&self) -> Box {