summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-04-12 19:43:39 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-04-12 19:43:39 +0000
commit364c46f010383a706967a6eaa8bbcf821f8d6772 (patch)
tree452d33ca04ecf728990b8bb66953fb95b46b146e /usr.bin
parentdb3ff3df8b6a21fd2e95c67af75725bec455d115 (diff)
Fix awk crash with empty assignment, e.g. 'BEGIN {i=$1}', when
malloc does not return zero-filled data. OK tb@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/awk/lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/awk/lib.c b/usr.bin/awk/lib.c
index 753fa8bffea..9d2b28beac7 100644
--- a/usr.bin/awk/lib.c
+++ b/usr.bin/awk/lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib.c,v 1.21 2015/03/27 10:09:30 tobiasu Exp $ */
+/* $OpenBSD: lib.c,v 1.22 2016/04/12 19:43:38 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -64,6 +64,7 @@ void recinit(unsigned int n)
|| (fldtab = (Cell **) calloc(nfields+1, sizeof(Cell *))) == NULL
|| (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
FATAL("out of space for $0 and fields");
+ *record = '\0';
*fldtab[0] = dollar0;
fldtab[0]->sval = record;
fldtab[0]->nval = tostring("0");