summaryrefslogtreecommitdiffstats
path: root/worm
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>1999-09-09 17:27:58 +0000
committerjsm <jsm@NetBSD.org>1999-09-09 17:27:58 +0000
commit05028c2aa439ddb8c5624303ab13b755c79e3930 (patch)
tree4dbfd0bd9517b044c230067c63c13f98608d7599 /worm
parent73294a12acd4e9ce3be5c49adc331ab62d3a398f (diff)
downloadbsdgames-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 'worm')
-rw-r--r--worm/worm.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/worm/worm.c b/worm/worm.c
index 34ef2cea..47e242c3 100644
--- a/worm/worm.c
+++ b/worm/worm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worm.c,v 1.14 1999/09/08 21:45:34 jsm Exp $ */
+/* $NetBSD: worm.c,v 1.15 1999/09/09 17:28:00 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: worm.c,v 1.14 1999/09/08 21:45:34 jsm Exp $");
+__RCSID("$NetBSD: worm.c,v 1.15 1999/09/09 17:28:00 jsm Exp $");
#endif
#endif /* not lint */
@@ -54,6 +54,7 @@ __RCSID("$NetBSD: worm.c,v 1.14 1999/09/08 21:45:34 jsm Exp $");
#include <ctype.h>
#include <curses.h>
+#include <err.h>
#include <signal.h>
#include <stdlib.h>
#include <termios.h>
@@ -151,12 +152,16 @@ life()
np = NULL;
head = newlink();
+ if (head == NULL)
+ errx(1, "out of memory");
head->x = start_len+2;
head->y = 12;
head->next = NULL;
display(head, HEAD);
for (i = 0, bp = head; i < start_len; i++, bp = np) {
np = newlink();
+ if (np == NULL)
+ errx(1, "out of memory");
np->next = bp;
bp->prev = np;
np->x = bp->x - 1;
@@ -277,6 +282,8 @@ process(ch)
}
else if(ch != ' ') crash();
nh = newlink();
+ if (nh == NULL)
+ errx(1, "out of memory");
nh->next = NULL;
nh->prev = head;
head->next = nh;