summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-09-26 07:23:07 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-09-26 07:23:07 +0000
commit284f3f8048a92363d901c1304cb336543887a33b (patch)
tree86e7c26d91920a093b5d7b98fe7b1a1a12767d35
parent6eaf622ca872513a384b705cdd35c8d1360dd06a (diff)
Check strdup() return value, as pointed out by deraadt@
-rw-r--r--usr.bin/bc/bc.y6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y
index a201110a9b4..9059846d5d9 100644
--- a/usr.bin/bc/bc.y
+++ b/usr.bin/bc/bc.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: bc.y,v 1.1 2003/09/25 19:32:44 otto Exp $ */
+/* $OpenBSD: bc.y,v 1.2 2003/09/26 07:23:06 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.1 2003/09/25 19:32:44 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bc.y,v 1.2 2003/09/26 07:23:06 otto Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -607,6 +607,8 @@ as(const char *str)
grow();
instructions[current].index = ALLOC_STRING;
instructions[current].u.astr = strdup(str);
+ if (instructions[current].u.astr == NULL)
+ err(1, "cannot allocate string");
return current++;
}