Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Memory leak in math expression parser
> On 06/06/2025 04:25 BST Ben Kallus <benjamin.p.kallus.gr@xxxxxxxxxxxxx> wrote:
> Zsh leaks 24 bytes when you run the following command:
> ```
> zsh -c '$((\(<< 0))'
> ```
Yes, that's real, thanks. Valgrind pointed to assigning a here-document
structure --- this is in a special parse context for the $(...)
subcommand, and the structure isn't freed when that context is popped.
I believe it really is a question of discarding the context completely
at that point, so I think this should do it.
pws
diff --git a/Src/parse.c b/Src/parse.c
index 8edc701..4ce5a46 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -340,6 +340,7 @@ parse_context_restore(const struct parse_stack *ps, int toplevel)
inrepeat_ = ps->inrepeat_;
intypeset = ps->intypeset;
+ clear_hdocs();
hdocs = ps->hdocs;
eclen = ps->eclen;
ecused = ps->ecused;
@@ -583,6 +584,7 @@ empty_eprog(Eprog p)
return (!p || !p->prog || *p->prog == WCB_END());
}
+/**/
static void
clear_hdocs(void)
{
Messages sorted by:
Reverse Date,
Date,
Thread,
Author