Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: memory leak (1): unset private parameter



On Fri, Jun 28, 2024 at 3:05 AM Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> When exiting from the function, endparmscope() (indirectly) calls
> unsetpm_pm(pm,, explicit=0), but it does not call
> pps_unsetfn(pm, expllicit=0) since PM_UNSET is already set
> (params.c:3793), and the gsu_closure is not freed.
>
> Maybe we need to set some info in pm to inform unsetpm_pm(pm)
> that gsu need be freed (but there is no flag PM_PRIVATE).

Seems to be sufficient to test PM_REMOVABLE; this sort of makes sense,
as removing the special from the parameter table conceivably requires
calling the GSU.

diff --git a/Src/params.c b/Src/params.c
index f65aa1e80..83bdb785d 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3790,7 +3790,7 @@ unsetparam_pm(Param pm, int altflag, int exp)
        altremove = NULL;

     pm->node.flags &= ~PM_DECLARED;    /* like ksh, not like bash */
-    if (!(pm->node.flags & PM_UNSET))
+    if (!(pm->node.flags & PM_UNSET) || (pm->node.flags & PM_REMOVABLE))
        pm->gsu.s->unsetfn(pm, exp);
     if (pm->env)
        delenv(pm);




Messages sorted by: Reverse Date, Date, Thread, Author