From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21137 invoked from network); 31 Oct 2007 16:39:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Oct 2007 16:39:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 26571 invoked from network); 31 Oct 2007 16:39:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Oct 2007 16:39:24 -0000 Received: (qmail 23664 invoked by alias); 31 Oct 2007 16:39:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24045 Received: (qmail 23644 invoked from network); 31 Oct 2007 16:39:21 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 31 Oct 2007 16:39:21 -0000 Received: (qmail 26272 invoked from network); 31 Oct 2007 16:39:21 -0000 Received: from esacom89-ext.esoc.esa.int (HELO esacom89-int.esoc.esa.int) (131.176.86.4) by a.mx.sunsite.dk with SMTP; 31 Oct 2007 16:39:15 -0000 Received: from esacom53.esoc.esa.int (131-176-86-254.esoc.esa.int [131.176.86.254]) by esacom89-int.esoc.esa.int (8.13.3/8.13.3/ESA-External-v4.0) with ESMTP id l9VGd6QD013616 for ; Wed, 31 Oct 2007 16:39:10 GMT Received: from dcle12.dev.esoc.esa.int (dcle12.dev.esoc.esa.int [131.176.58.71]) by esacom53.esoc.esa.int (8.12.10/8.12.10/ESA-Internal-v3.2) with ESMTP id l9VGcvlc024717 for ; Wed, 31 Oct 2007 16:39:01 GMT Received: from dcle12 (localhost [127.0.0.1]) by dcle12.dev.esoc.esa.int (8.13.8+Sun/8.13.8) with ESMTP id l9VGctDn002756 for ; Wed, 31 Oct 2007 16:38:56 GMT From: Oliver Kiddle To: Zsh workers Subject: PATCH: fix memory leak in new setenv code Date: Wed, 31 Oct 2007 17:38:55 +0100 Message-ID: <2755.1193848735@dcle12> 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 /*