summaryrefslogtreecommitdiff
path: root/src/tr.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-07-13 15:45:24 +0000
committerJim Meyering <jim@meyering.net>1994-07-13 15:45:24 +0000
commitdd4604716868b41238af0266423edf3bd0aa56ae (patch)
treed6546bf192609a25794cb154e003f0b6158aff26 /src/tr.c
parent35b631eb04d16bdb4d1d6f20ded8ea73342f919a (diff)
downloadcoreutils-dd4604716868b41238af0266423edf3bd0aa56ae.tar.xz
(substr): Allocate len+1 bytes (not just len) to leave room for trailing NUL.
Diffstat (limited to 'src/tr.c')
-rw-r--r--src/tr.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tr.c b/src/tr.c
index fe899c0fe..e34eae180 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -814,7 +814,7 @@ substr (p, first_idx, last_idx)
int last_idx;
{
int len = last_idx - first_idx + 1;
- unsigned char *tmp = (unsigned char *) xmalloc (len);
+ unsigned char *tmp = (unsigned char *) xmalloc (len + 1);
assert (first_idx <= last_idx);
/* We must use bcopy or memcpy rather than strncpy