9front - general discussion about 9front
 help / color / mirror / Atom feed
* bug: awk crash (patch included)
@ 2019-04-25  4:42 Pete
  2019-04-25 16:46 ` [9front] " Nick Owens
  0 siblings, 1 reply; 3+ messages in thread
From: Pete @ 2019-04-25  4:42 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

Here is a patch for an awk crash.  The crash can be reproduced by doing
this:

    % awk 'BEGIN{nextfile}'

This is an illegal awk program, but instead of printing the error
message, it tries to Bterm(nil) and doesn't get as far as the error
message.  The patch fixes that and awk spits out the error instead of 
crashing.

(Sorry for the cross-post, someone on the grid told me the main ML was a
better place to send this than 9front-bugs.)

[-- Attachment #2: awk.patch --]
[-- Type: text/plain, Size: 310 bytes --]

diff -r b1bd262dc055 sys/src/cmd/awk/lib.c
--- a/sys/src/cmd/awk/lib.c	Mon Apr 15 19:48:03 2019 +0000
+++ b/sys/src/cmd/awk/lib.c	Mon Apr 15 15:52:22 2019 -0700
@@ -167,7 +167,7 @@
 
 void nextfile(void)
 {
-	if (infile != &stdin)
+	if (infile && infile != &stdin)
 		Bterm(infile);
 	infile = nil;
 	argno++;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-25 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25  4:42 bug: awk crash (patch included) Pete
2019-04-25 16:46 ` [9front] " Nick Owens
2019-04-25 18:11   ` Pete

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).