summaryrefslogtreecommitdiff
path: root/usr.bin/awk
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-11-23 02:43:46 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-11-23 02:43:46 +0000
commitd770c0144b052d846889a0e2bf14814e788fce8a (patch)
treec9a5a1437a8a379edce114767e405561492cee74 /usr.bin/awk
parentb4b298ebd16b2e5a1370290887b1157f3982ea3b (diff)
Don't try to fclose(infile) when infile == NULL. This can happen
when using nextfile in the BEGIN block. From Matthias Kilian.
Diffstat (limited to 'usr.bin/awk')
-rw-r--r--usr.bin/awk/lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/awk/lib.c b/usr.bin/awk/lib.c
index 8b969b78f48..a9204a1ee01 100644
--- a/usr.bin/awk/lib.c
+++ b/usr.bin/awk/lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib.c,v 1.15 2004/12/30 01:52:48 millert Exp $ */
+/* $OpenBSD: lib.c,v 1.16 2005/11/23 02:43:45 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -176,7 +176,7 @@ int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */
void nextfile(void)
{
- if (infile != stdin)
+ if (infile != stdin && infile != NULL)
fclose(infile);
infile = NULL;
argno++;