diff options
author | Jim Meyering <jim@meyering.net> | 1994-07-13 15:45:24 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-07-13 15:45:24 +0000 |
commit | dd4604716868b41238af0266423edf3bd0aa56ae (patch) | |
tree | d6546bf192609a25794cb154e003f0b6158aff26 /src/tr.c | |
parent | 35b631eb04d16bdb4d1d6f20ded8ea73342f919a (diff) | |
download | coreutils-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 |