aboutsummaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2011-05-03 11:37:03 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2011-05-03 11:37:03 +0000
commitbd726c262eacb8675c29121f040452106671e929 (patch)
tree3d195e2a98d7d1d827a1d40f49e6529b3bfc6825 /lib.c
parentd9859a0e4b8744c01f13cf391ee5cfbf57c5e818 (diff)
downloadsrc-bd726c262eacb8675c29121f040452106671e929.tar.gz
src-bd726c262eacb8675c29121f040452106671e929.zip
Vendor import of bwk's 1-May-2011 release.vendor/one-true-awk/20110501
Notes
Notes: svn path=/vendor/one-true-awk/dist/; revision=221379 svn path=/vendor/one-true-awk/20110501/; revision=221380; tag=vendor/one-true-awk/20110501
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 017b37670d07..d7eee31db43f 100644
--- a/lib.c
+++ b/lib.c
@@ -256,6 +256,7 @@ void fldbld(void) /* create fields from current record */
{
/* this relies on having fields[] the same length as $0 */
/* the fields are all stored in this one array with \0's */
+ /* possibly with a final trailing \0 not associated with any field */
char *r, *fr, sep;
Cell *p;
int i, j, n;
@@ -268,7 +269,7 @@ void fldbld(void) /* create fields from current record */
n = strlen(r);
if (n > fieldssize) {
xfree(fields);
- if ((fields = (char *) malloc(n+1)) == NULL)
+ if ((fields = (char *) malloc(n+2)) == NULL) /* possibly 2 final \0s */
FATAL("out of space for fields in fldbld %d", n);
fieldssize = n;
}