From 854a4dc348025dc8044f1132e63561e4249a2f87 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 1 Aug 2003 09:57:32 +0000 Subject: 18916: unsetting IFS could cause segfault --- Src/utils.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Src') 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++); -- cgit 1.4.1