aboutsummaryrefslogtreecommitdiff
path: root/stringlib.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2014-02-26 09:36:43 -0500
committerChet Ramey <chet.ramey@case.edu>2014-02-26 09:36:43 -0500
commitac50fbac377e32b98d2de396f016ea81e8ee9961 (patch)
treef71882366b98fedf1a88a063103219a4935de926 /stringlib.c
parent4539d736f1aff232857a854fd2a68df0c98d9f34 (diff)
Bash-4.3 distribution sources and documentation
Diffstat (limited to 'stringlib.c')
-rw-r--r--stringlib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stringlib.c b/stringlib.c
index 0a612ca..9509299 100644
--- a/stringlib.c
+++ b/stringlib.c
@@ -133,7 +133,7 @@ substring (string, start, end)
len = end - start;
result = (char *)xmalloc (len + 1);
- strncpy (result, string + start, len);
+ memcpy (result, string + start, len);
result[len] = '\0';
return (result);
}
@@ -158,7 +158,7 @@ strsub (string, pat, rep, global)
if (replen)
RESIZE_MALLOCED_BUFFER (temp, templen, replen, tempsize, (replen * 2));
- for (r = rep; *r; )
+ for (r = rep; *r; ) /* can rep == "" */
temp[templen++] = *r++;
i += patlen ? patlen : 1; /* avoid infinite recursion */