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

PATCH: loadautofn memory leak



getfpfunc allocates memory for fname, which was not freed one these
codepaths.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.152
diff -u -r1.152 exec.c
--- Src/exec.c	16 Sep 2008 15:06:57 -0000	1.152
+++ Src/exec.c	21 Sep 2008 12:38:45 -0000
@@ -4134,10 +4134,13 @@
 	zwarn("%s: function definition file not found", shf->node.nam);
 	locallevel++;
 	popheap();
+	zsfree(fname);
 	return NULL;
     }
-    if (!prog)
+    if (!prog) {
+	zsfree(fname);
 	return NULL;
+    }
     if (ksh == 2 || (ksh == 1 && isset(KSHAUTOLOAD))) {
 	if (autol) {
 	    prog->flags |= EF_RUN;
@@ -4174,6 +4177,7 @@
 	shf->filename = fname;
     }
     popheap();
+    zsfree(fname);
 
     return shf;
 }



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