I think it is best to simply initialize "record" to be the empty
string.  This is sufficient to fix the crash.

 - todd

Index: usr.bin/awk/lib.c
===================================================================
RCS file: /cvs/src/usr.bin/awk/lib.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 lib.c
--- usr.bin/awk/lib.c   27 Mar 2015 10:09:30 -0000      1.21
+++ usr.bin/awk/lib.c   12 Apr 2016 17:02:27 -0000
@@ -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");

Reply via email to