zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh workers <zsh-workers@sunsite.dk>
Subject: PATCH: fix memory leak in new setenv code
Date: Wed, 31 Oct 2007 17:38:55 +0100	[thread overview]
Message-ID: <2755.1193848735@dcle12> (raw)

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
     /*


             reply	other threads:[~2007-10-31 16:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31 16:38 Oliver Kiddle [this message]
2007-11-22  2:57 ` Geoff Wing
2007-11-22  7:40   ` Bart Schaefer
2007-11-23  0:00     ` Geoff Wing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2755.1193848735@dcle12 \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).