diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1998-09-16 00:44:38 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1998-09-16 00:44:38 +0000 |
commit | 11fe28977822e0d301e52c65e35c79866a757bf3 (patch) | |
tree | 0dad2d9fb94b4aec0fc2b56987fc3ee3e4a27f29 /games/rogue/init.c | |
parent | 8896bd95b7432af011cd98842289c9c1124a2dc6 (diff) |
Make sure malloc() succeeds
Diffstat (limited to 'games/rogue/init.c')
-rw-r--r-- | games/rogue/init.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/games/rogue/init.c b/games/rogue/init.c index f413d0c3338..c1d9639dea7 100644 --- a/games/rogue/init.c +++ b/games/rogue/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.4 1998/08/22 08:55:27 pjanzen Exp $ */ +/* $OpenBSD: init.c,v 1.5 1998/09/16 00:44:36 pjanzen Exp $ */ /* $NetBSD: init.c,v 1.4 1995/04/28 23:49:19 mycroft Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: init.c,v 1.4 1998/08/22 08:55:27 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: init.c,v 1.5 1998/09/16 00:44:36 pjanzen Exp $"; #endif #endif /* not lint */ @@ -57,6 +57,7 @@ static char rcsid[] = "$OpenBSD: init.c,v 1.4 1998/08/22 08:55:27 pjanzen Exp $" * */ +#include <err.h> #include "rogue.h" char login_name[MAX_OPT_LEN]; @@ -334,7 +335,8 @@ env_get_value(s, e, add_blank) break; } } - *s = md_malloc(MAX_OPT_LEN + 2); + if (!(*s = md_malloc(MAX_OPT_LEN + 2))) + errx(1, "malloc failure"); (void) strncpy(*s, t, i); if (add_blank) { (*s)[i++] = ' '; @@ -347,7 +349,8 @@ init_str(str, dflt) char **str, *dflt; { if (!(*str)) { - *str = md_malloc(MAX_OPT_LEN + 2); + if (!(*str = md_malloc(MAX_OPT_LEN + 2))) + errx(1, "malloc failure"); (void) strcpy(*str, dflt); } } |