user/4887: awk(1) segfaults on nextfile in the BEGIN block

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

user/4887: awk(1) segfaults on nextfile in the BEGIN block

Matthias Kilian
>Number:         4887
>Category:       user
>Synopsis:       awk(1) segfaults on nextfile in the BEGIN block
>Confidential:   yes
>Severity:       non-critical
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:      
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 22 21:10:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Kilian
>Release:        3.8
>Organization:
net
>Environment:
        System      : OpenBSD 3.8
        Architecture: OpenBSD.i386
        Machine     : i386
>Description:
        The nextfile statement, when issued with an awk BEGIN block,
        causes a segmentation fault instead of just printing an
        explanatory error message.
>How-To-Repeat:
        $ awk 'BEGIN {nextfile}' foo
>Fix:
--- lib.c.orig Thu Dec 30 14:06:17 2004
+++ lib.c Tue Nov 22 21:46:22 2005
@@ -176,7 +176,7 @@
 
 void nextfile(void)
 {
- if (infile != stdin)
+ if (infile != stdin && infile != NULL)
  fclose(infile);
  infile = NULL;
  argno++;


>Release-Note:
>Audit-Trail:
>Unformatted: