diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-09-18 19:29:42 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-09-18 19:29:42 +0000 |
commit | 3b2008ae4eb3658c4f72d9a4ee32cba6a484f582 (patch) | |
tree | ce869af707def049ef46dee2ad4d07cda6cc45c8 | |
parent | c546b91a9028602f706cc888a2b220b87661d43d (diff) |
Do not check pointer for NULL, but check for return value of asprintf(),
like the man page says.
-rw-r--r-- | usr.bin/bc/bc.y | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y index aff24ca1b4d..64d098d0eba 100644 --- a/usr.bin/bc/bc.y +++ b/usr.bin/bc/bc.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: bc.y,v 1.26 2005/05/23 06:44:58 otto Exp $ */ +/* $OpenBSD: bc.y,v 1.27 2005/09/18 19:29:41 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.26 2005/05/23 06:44:58 otto Exp $"; +static const char rcsid[] = "$OpenBSD: bc.y,v 1.27 2005/09/18 19:29:41 otto Exp $"; #endif /* not lint */ #include <ctype.h> @@ -931,17 +931,19 @@ void yyerror(char *s) { char *str, *p; + int n; if (feof(yyin)) - asprintf(&str, "%s: %s:%d: %s: unexpected EOF", + n = asprintf(&str, "%s: %s:%d: %s: unexpected EOF", __progname, filename, lineno, s); else if (isspace(yytext[0]) || !isprint(yytext[0])) - asprintf(&str, "%s: %s:%d: %s: ascii char 0x%02x unexpected", + n = asprintf(&str, + "%s: %s:%d: %s: ascii char 0x%02x unexpected", __progname, filename, lineno, s, yytext[0]); else - asprintf(&str, "%s: %s:%d: %s: %s unexpected", + n = asprintf(&str, "%s: %s:%d: %s: %s unexpected", __progname, filename, lineno, s, yytext); - if (str == NULL) + if (n == -1) err(1, NULL); fputs("c[", stdout); |