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

PATCH: Crash with 'print -s' with no further arguments



On Thu, Mar 20, 2003 at 04:40:07AM +0000, Miciah Dashiel Butler Masters wrote:
> $ zsh -f
> AwesomeComp% setopt hist_ignore_all_dups
> AwesomeComp% print -s
> AwesomeComp% print -s
> Segmentation fault

This turns out to be a bug in the zjoin() function when it generates
an empty string and the heap flag is not set.  This patch fixes the
problem:

--- Src/utils.c	24 Mar 2003 12:57:25 -0000	1.47
+++ Src/utils.c	25 Mar 2003 17:57:07 -0000
@@ -1793,7 +1793,7 @@
     for (s = arr; *s; s++)
 	len += strlen(*s) + 1;
     if (!len)
-	return "";
+	return heap? "" : ztrdup("");
     ptr = ret = (heap ? (char *) hcalloc(len) : (char *) zcalloc(len));
     for (s = arr; *s; s++) {
 	strucpy(&ptr, *s);

This should also fix any other crash bug that was caused by typing
"print -s" (without any args) -- the only difference is when the code
will try to free the literal "" string.

..wayne..



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