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

Re: PATCH: fix for SEGV



On Aug 26,  9:16am, Sven Wischnowsky wrote:
} Subject: Re: PATCH: fix for SEGV
}
} Bart Schaefer wrote:
} 
} > On Aug 24,  2:16pm, Sven Wischnowsky wrote:
} > } Subject: PATCH: fix for SEGV
} > } 
} > } +    if (cn->flags & HASHED)
} > } +	return 1;
} > 
} > Is that really the right fix?
} 
} I wasn't sure either and was hoping for a reply. isreallycom() is used
} only in one place, so we could easily move the extra test there.
} 
} -	    if (hn && trycd && !isreallycom((Cmdnam)hn)) {
} +	    if (hn && trycd && !(((Cmdnam)hn)->flags & HASHED) &&
} +		!isreallycom((Cmdnam)hn)) {

Actually, I was rather thinking more of something like this (which goes
on top of 7490, which went on top of 7472):

Index: exec.c
===================================================================
@@ -617,9 +617,15 @@
 {
     char fullnam[MAXCMDLEN];
 
-    strcpy(fullnam, cn->u.name ? *(cn->u.name) : "");
-    strcat(fullnam, "/");
-    strcat(fullnam, cn->nam);
+    if (cn->flags & HASHED)
+	strcpy(fullnam, cn->u.cmd);
+    else if (!cn->u.name)
+	return 0;
+    else {
+	strcpy(fullnam, cn->u.name);
+	strcat(fullnam, "/");
+	strcat(fullnam, cn->nam);
+    }
     return iscom(fullnam);
 }
 
@@ -1685,8 +1691,7 @@
 	    char *cmdarg = (char *) peekfirst(args);
 
 	    hn = cmdnamtab->getnode(cmdnamtab, cmdarg);
-	    if (hn && trycd && !(((Cmdnam)hn)->flags & HASHED) &&
-		!isreallycom((Cmdnam)hn)) {
+	    if (hn && trycd && !isreallycom((Cmdnam)hn)) {
 		cmdnamtab->removenode(cmdnamtab, cmdarg);
 		cmdnamtab->freenode(hn);
 		hn = NULL;

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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