From 05028c2aa439ddb8c5624303ab13b755c79e3930 Mon Sep 17 00:00:00 2001 From: jsm Date: Thu, 9 Sep 1999 17:27:58 +0000 Subject: Check for failure of malloc() and calloc() at various places in the games. --- worm/worm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'worm/worm.c') 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 #include +#include #include #include #include @@ -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; -- cgit v1.2.3