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;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Beof arrived on this file; set up next */
|
/* Beof arrived on this file; set up next */
|
||||||
if (infile != &stdin)
|
nextfile();
|
||||||
Bterm(infile);
|
|
||||||
infile = nil;
|
|
||||||
argno++;
|
|
||||||
}
|
}
|
||||||
*pbuf = buf;
|
*pbuf = buf;
|
||||||
*pbufsize = bufsize;
|
*pbufsize = bufsize;
|
||||||
|
@ -167,7 +164,7 @@ int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */
|
||||||
|
|
||||||
void nextfile(void)
|
void nextfile(void)
|
||||||
{
|
{
|
||||||
if (infile != &stdin)
|
if (infile != nil && infile != &stdin)
|
||||||
Bterm(infile);
|
Bterm(infile);
|
||||||
infile = nil;
|
infile = nil;
|
||||||
argno++;
|
argno++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue