Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Memory leaks found by valgrind



Felix Rosencrantz wrote:
> The only new leak I found was the following.   This I believe is related
> to replace-string command.  When I tried that widget, I would get more
> leaks.  (I haven't tried using other recent features/changes.)
>  62 bytes in 62 blocks are definitely lost in loss record 5 of 13
>     at 0x40165A60: malloc (vg_clientfuncs.c:100)
>     by 0x8086275: zalloc (mem.c:490)
>     by 0x810536C: set_prepost (zle_params.c:485)
>     by 0x810541E: set_postdisplay (zle_params.c:515)
>     by 0x808F7F4: setstrvalue (params.c:1608)
>     by 0x8090BAC: assignsparam (params.c:1994)
>     by 0x805F0A6: addvars (exec.c:1598)
>     by 0x805CDC9: execsimple (exec.c:756)

This could be the following, which needs patching anyway.

Index: Src/Zle/zle_params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_params.c,v
retrieving revision 1.8
diff -u -r1.8 zle_params.c
--- Src/Zle/zle_params.c	27 Jan 2003 14:55:02 -0000	1.8
+++ Src/Zle/zle_params.c	5 Mar 2003 13:58:09 -0000
@@ -482,8 +482,10 @@
     }
     if (x) {
 	unmetafy(x, lenvar);
-	*textvar = (unsigned char *)zalloc(*lenvar);
-	memcpy((char *)*textvar, x, *lenvar);
+	if (*lenvar) {
+	    *textvar = (unsigned char *)zalloc(*lenvar);
+	    memcpy((char *)*textvar, x, *lenvar);
+	}
 	free(x);
     }
 }

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author