Apply r323963 from FreeBSD (pulling in the fix from OpenBSD)

| Fix uninitialized variable
|
| echo | awk 'BEGIN {i=$1; print i}' prints a boatload of stack
| garbage. NUL terminate the memory returned from malloc to prevent it.
|
| Obtained from: OpenBSD run.c 1.40
| Sponsored by: Netflix
| Differential Revision: https://reviews.freebsd.org/D12379
This commit is contained in:
M. Warner Losh 2019-06-02 15:17:29 -06:00 committed by Arnold D. Robbins
parent 966fdc9c29
commit 0939e3392b

1
lib.c
View File

@ -62,6 +62,7 @@ void recinit(unsigned int n)
|| (fldtab = (Cell **) malloc((nfields+2) * 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");