zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: leak in parameter structures
@ 2005-11-02 11:59 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2005-11-02 11:59 UTC (permalink / raw)
  To: Zsh hackers list

Valgrind spotted a leak with the ename element of parameters which
I've hacked around a few times and still not got right... the unset
function gets called before the structure is freed, as one would expect,
but it unsets the PM_TIED flag so that when the structure is freed the
ename isn't.  It's a bit hairy since if PM_SPECIAL is set we don't want
to free it.

That's enough detail.  I think the following is probably safe.

Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.105
diff -u -r1.105 params.c
--- Src/params.c	13 Oct 2005 16:30:14 -0000	1.105
+++ Src/params.c	2 Nov 2005 11:57:21 -0000
@@ -2452,8 +2452,13 @@
 	    	pm->u.str = NULL;
 	    break;
     }
-    if (!(pm->flags & PM_SPECIAL))
+    if ((pm->flags & (PM_SPECIAL|PM_TIED)) == PM_TIED) {
+	if (pm->ename) {
+	    zsfree(pm->ename);
+	    pm->ename = NULL;
+	}
 	pm->flags &= ~PM_TIED;
+    }
     pm->flags |= PM_UNSET;
 }
 
-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-02 11:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-02 11:59 PATCH: leak in parameter structures Peter Stephenson

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).