diff options
author | jsm <jsm@NetBSD.org> | 1999-09-09 17:27:58 +0000 |
---|---|---|
committer | jsm <jsm@NetBSD.org> | 1999-09-09 17:27:58 +0000 |
commit | 05028c2aa439ddb8c5624303ab13b755c79e3930 (patch) | |
tree | 4dbfd0bd9517b044c230067c63c13f98608d7599 /monop/monop.c | |
parent | 73294a12acd4e9ce3be5c49adc331ab62d3a398f (diff) | |
download | bsdgames-darwin-05028c2aa439ddb8c5624303ab13b755c79e3930.tar.gz bsdgames-darwin-05028c2aa439ddb8c5624303ab13b755c79e3930.tar.zst bsdgames-darwin-05028c2aa439ddb8c5624303ab13b755c79e3930.zip |
Check for failure of malloc() and calloc() at various places in the games.
Diffstat (limited to 'monop/monop.c')
-rw-r--r-- | monop/monop.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/monop/monop.c b/monop/monop.c index 001331cb..5b071759 100644 --- a/monop/monop.c +++ b/monop/monop.c @@ -1,4 +1,4 @@ -/* $NetBSD: monop.c,v 1.7 1999/09/08 21:45:28 jsm Exp $ */ +/* $NetBSD: monop.c,v 1.8 1999/09/09 17:27:59 jsm Exp $ */ /* * Copyright (c) 1980, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ #if 0 static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: monop.c,v 1.7 1999/09/08 21:45:28 jsm Exp $"); +__RCSID("$NetBSD: monop.c,v 1.8 1999/09/09 17:27:59 jsm Exp $"); #endif #endif /* not lint */ @@ -116,6 +116,8 @@ blew_it: break; } cur_p = play = (PLAY *) calloc(num_play, sizeof (PLAY)); + if (play == NULL) + errx(1, "out of memory"); for (i = 0; i < num_play; i++) { over: printf("Player %d's name: ", i + 1); @@ -124,7 +126,10 @@ over: if (sp == buf) goto over; *sp++ = '\0'; - strcpy(name_list[i]=play[i].name=(char *)calloc(1,sp-buf),buf); + name_list[i] = play[i].name = (char *)calloc(1, sp - buf); + if (name_list[i] == NULL) + errx(1, "out of memory"); + strcpy(play[i].name, buf); play[i].money = 1500; } name_list[i++] = "done"; |