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

PATCH: fix memory leak in new setenv code



I noticed using Solaris libumem and mdb that zsh is leaking memory
every time an environment variable is modified. I traced this down to
some relatively recent change to use setenv(3) and the fact that the
old value was not being freed. I think the patch below is the correct
fix.

Oliver

--- Src/params.c.orig	Wed Oct 31 17:30:57 2007
+++ Src/params.c	Wed Oct 31 17:28:49 2007
@@ -3998,6 +3998,8 @@
       * the other branch?  If so, we don't actually need to
       * store pm->env at all, just a flag that the value was set.
       */
+     if (pm->env)
+         zsfree(pm->env);
      pm->env = newenv;
 #else
     /*



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