summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2016-04-12 19:43:38 +0000
committermillert <millert@openbsd.org>2016-04-12 19:43:38 +0000
commit6b41c7282b1bd6377b3e67b7b7078d2a793362cc (patch)
treeb57fc4a2613bc4704361462f3c97b62e83f00fd9
parenttwo times a define to an inline function, from Michael McConville; ok djm@ (diff)
downloadwireguard-openbsd-6b41c7282b1bd6377b3e67b7b7078d2a793362cc.tar.xz
wireguard-openbsd-6b41c7282b1bd6377b3e67b7b7078d2a793362cc.zip
Fix awk crash with empty assignment, e.g. 'BEGIN {i=$1}', when
malloc does not return zero-filled data. OK tb@
-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");