awk: fix nextfile crash (thanks leetspete)
to reproduce the bug: term% awk 'BEGIN{nextfile; nextfile;}' sys: trap: fault read addr=0x10 pc=0x00019a3a awk 6584: suicide: sys: trap: fault read addr=0x10 pc=0x00019a3a
This commit is contained in:
parent
75ee3b3081
commit
7c33bdd2d3
1 changed files with 2 additions and 5 deletions
|
@ -155,10 +155,7 @@ int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */
|
|||
return 1;
|
||||
}
|
||||
/* Beof arrived on this file; set up next */
|
||||
if (infile != &stdin)
|
||||
Bterm(infile);
|
||||
infile = nil;
|
||||
argno++;
|
||||
nextfile();
|
||||
}
|
||||
*pbuf = buf;
|
||||
*pbufsize = bufsize;
|
||||
|
@ -167,7 +164,7 @@ int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */
|
|||
|
||||
void nextfile(void)
|
||||
{
|
||||
if (infile != &stdin)
|
||||
if (infile != nil && infile != &stdin)
|
||||
Bterm(infile);
|
||||
infile = nil;
|
||||
argno++;
|
||||
|
|
Loading…
Reference in a new issue