diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-05-18 05:49:54 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-05-18 05:49:54 +0000 |
commit | d7f4b35e67a39f0e497ff7dc656894f843c63c3b (patch) | |
tree | 394cb52fb489e75ea1f1f2df5e5d8776ca75ebe8 | |
parent | cf243f928da09372df41a40335a1d865cf2737c8 (diff) |
Avoid segv when a syntax error occurs while reading from command line.
found by jmc@
-rw-r--r-- | usr.bin/bc/bc.y | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index 9ba079c55e5..13de85c241b 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: bc.y,v 1.31 2006/04/20 20:00:46 deraadt Exp $ */ +/* $OpenBSD: bc.y,v 1.32 2006/05/18 05:49:53 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -31,7 +31,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: bc.y,v 1.31 2006/04/20 20:00:46 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: bc.y,v 1.32 2006/05/18 05:49:53 otto Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -944,7 +944,7 @@ yyerror(char *s) char *str, *p; int n; - if (feof(yyin)) + if (yyin != NULL && feof(yyin)) n = asprintf(&str, "%s: %s:%d: %s: unexpected EOF", __progname, filename, lineno, s); else if (isspace(yytext[0]) || !isprint(yytext[0])) |