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

PATCH: potential memory leak in bin_compadd



mstr might be allocated in an earlier run of the loop, and then not
freed on these errors.

Index: Src/Zle/complete.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complete.c,v
retrieving revision 1.40
diff -u -r1.40 complete.c
--- Src/Zle/complete.c	8 Jun 2008 17:53:55 -0000	1.40
+++ Src/Zle/complete.c	14 Sep 2008 08:34:16 -0000
@@ -679,10 +679,12 @@
                     p = "" - 1;
                 } else {
                     zwarnnam(name, "number expected after -%c", *p);
+		    zsfree(mstr);
                     return 1;
                 }
                 if (dat.dummies < 0) {
                     zwarnnam(name, "invalid number: %d", dat.dummies);
+		    zsfree(mstr);
                     return 1;
                 }
 		break;
@@ -691,6 +693,7 @@
 		goto ca_args;
 	    default:
 		zwarnnam(name, "bad option: -%c", *p);
+		zsfree(mstr);
 		return 1;
 	    }
 	    if (sp) {



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