summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-08-01 09:55:38 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-08-01 09:55:38 +0000
commit74678a3435b92d2376f5ad2a648b0350884c70cc (patch)
tree05d49cd5f965d7796ff4b091ea33edbab833a667
parent795d7872b61c44acabb79bb524dc040a6a998a9f (diff)
downloadzsh-74678a3435b92d2376f5ad2a648b0350884c70cc.tar.gz
zsh-74678a3435b92d2376f5ad2a648b0350884c70cc.zip
18916: unsetting IFS could cause segfault
-rw-r--r--ChangeLog5
-rw-r--r--Src/utils.c10
2 files changed, 11 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 53bbe6bf5..2969044a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-08-01 Peter Stephenson <pws@csr.com>
+
+ * 18916: Src/utils.c: Unsetting IFS could cause segmentation
+ fault (any time IFS was used to join an array).
+
2003-07-31 Oliver Kiddle <opk@zsh.org>
* 18914: Completion/Base/Utility/_nothing,
diff --git a/Src/utils.c b/Src/utils.c
index dd8794ca6..c83268422 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2054,10 +2054,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++);