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

PATCH: avoid use of variable after free in getmathfunc()



removemathfunc frees p (but does not set it to NULL)

Index: Src/module.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/module.c,v
retrieving revision 1.39
diff -u -r1.39 module.c
--- Src/module.c	4 Aug 2008 15:26:32 -0000	1.39
+++ Src/module.c	14 Oct 2008 23:36:04 -0000
@@ -1266,10 +1266,11 @@
 	if (!strcmp(name, p->name)) {
 	    if (autol && p->module && !(p->flags & MFF_USERFUNC)) {
 		char *n = dupstring(p->module);
+		int flags = p->flags;
 
 		removemathfunc(q, p);
 
-		(void)ensurefeature(n, "f:", (p->flags & MFF_AUTOALL) ? NULL :
+		(void)ensurefeature(n, "f:", (flags & MFF_AUTOALL) ? NULL :
 				    name);
 
 		return getmathfunc(name, 0);



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