zsh-workers
 help / color / mirror / code / Atom feed
From: Geoff Wing <gcw@zsh.org>
To: Zsh Hackers <zsh-workers@sunsite.dk>
Subject: Re: PATCH: fix memory leak in new setenv code
Date: Thu, 22 Nov 2007 13:57:11 +1100	[thread overview]
Message-ID: <20071122025711.GA4745@primenet.com.au> (raw)
In-Reply-To: <2755.1193848735@dcle12>

On Thursday 2007-11-01 03:39 +1100, Oliver Kiddle output:
: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
:     /*
:

This can't be right and corrupts my environment (using zsh memory
routines).  Running "env" spews out lots of bad stuff.

If we're supposed to be zsfree()ing that, why aren't we doing it
consistently, i.e. around the line which assigns newenv and before
the call to zputenv()?  Maybe it should be managed differently?

Regards,


  reply	other threads:[~2007-11-22  2:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31 16:38 Oliver Kiddle
2007-11-22  2:57 ` Geoff Wing [this message]
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=20071122025711.GA4745@primenet.com.au \
    --to=gcw@zsh.org \
    --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).