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

PATCH: bug with hash builtin



This was found by coverity:

hash =
causes a seg fault.

A patch is below. I'm not sure about the error message because it isn't
really an assignment but I can't think of anything better. Does anyone
think it would be better to avoid the use of the continue statement here
at the cost of having to further indent quite a few lines.

Oliver

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.215
diff -u -r1.215 builtin.c
--- Src/builtin.c	30 Oct 2008 19:52:44 -0000	1.215
+++ Src/builtin.c	31 Oct 2008 11:00:22 -0000
@@ -3262,7 +3262,7 @@
     }
 
     queue_signals();
-    while (*argv) {
+    for (;*argv;++argv) {
 	void *hn;
 	if (OPT_ISSET(ops,'m')) {
 	    /* with the -m option, treat the argument as a glob pattern
*/
@@ -3275,7 +3275,12 @@
 		zwarnnam(name, "bad pattern : %s", *argv);
 		returnval = 1;
 	    }
-	} else if ((asg = getasg(*argv)) && asg->value) {
+            continue;
+	}
+        if (!(asg = getasg(*argv))) {
+	    zwarnnam(name, "bad assignment");
+	    returnval = 1;
+        } else if (asg->value) {
 	    if(isset(RESTRICTED)) {
 		zwarnnam(name, "restricted: %s", asg->value);
 		returnval = 1;
@@ -3323,7 +3328,6 @@
 		ht->printnode(hn, 0);
 	} else if(OPT_ISSET(ops,'v'))
 	    ht->printnode(hn, 0);
-	argv++;
     }
     unqueue_signals();
     return returnval;




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