Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: leak in parameter structures
- X-seq: zsh-workers 21974
 
- From: Peter Stephenson <pws@xxxxxxx>
 
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
 
- Subject: PATCH: leak in parameter structures
 
- Date: Wed, 02 Nov 2005 11:59:16 +0000
 
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
 
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@xxxxxxx>                  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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author