about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-08-01 09:57:32 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-08-01 09:57:32 +0000
commit854a4dc348025dc8044f1132e63561e4249a2f87 (patch)
treea5a8c3b24c633a0a66d445b291dcb96a79a7f5b3 /Src
parent59f986694ee1c24b027bc9e56171d48d7ef46987 (diff)
downloadzsh-854a4dc348025dc8044f1132e63561e4249a2f87.tar.gz
zsh-854a4dc348025dc8044f1132e63561e4249a2f87.tar.xz
zsh-854a4dc348025dc8044f1132e63561e4249a2f87.zip
18916: unsetting IFS could cause segfault
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 292f9cc89..4a6c1d3f6 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2029,10 +2029,12 @@ sepjoin(char **s, char *sep, int heap)
     if (!*s)
 	return heap ? "" : ztrdup("");
     if (!sep) {
-	sep = sepbuf;
-	sepbuf[0] = *ifs;
-	sepbuf[1] = *ifs == Meta ? ifs[1] ^ 32 : '\0';
-	sepbuf[2] = '\0';
+	p = sep = sepbuf;
+	if (ifs) {
+	    *p++ = *ifs;
+	    *p++ = *ifs == Meta ? ifs[1] ^ 32 : '\0';
+	}
+	*p = '\0';
     }
     sl = strlen(sep);
     for (t = s, l = 1 - sl; *t; l += strlen(*t) + sl, t++);