From d7f4b35e67a39f0e497ff7dc656894f843c63c3b Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 18 May 2006 05:49:54 +0000 Subject: Avoid segv when a syntax error occurs while reading from command line. found by jmc@ --- usr.bin/bc/bc.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.bin') 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 @@ -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 @@ -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])) -- cgit v1.2.3