diff options
author | hubertf <hubertf@NetBSD.org> | 1999-07-24 23:58:15 +0000 |
---|---|---|
committer | hubertf <hubertf@NetBSD.org> | 1999-07-24 23:58:15 +0000 |
commit | 47c4a13aeb96fe1fe49bddec4fb90e77c81cf366 (patch) | |
tree | 2165850039dca8896972027e0810bc24902dc72f /atc | |
parent | a4477ce63070b816df1ad7f347b2c267f0d9d752 (diff) | |
download | bsdgames-darwin-47c4a13aeb96fe1fe49bddec4fb90e77c81cf366.tar.gz bsdgames-darwin-47c4a13aeb96fe1fe49bddec4fb90e77c81cf366.tar.zst bsdgames-darwin-47c4a13aeb96fe1fe49bddec4fb90e77c81cf366.zip |
This patch makes atc(6) check for memory allocation failure.
Patch submitted by Joseph Myers <jsm28@cam.ac.uk> in PR 8056,
with small enhancement to make clearer when loser() is called
with NULL.
Diffstat (limited to 'atc')
-rw-r--r-- | atc/graphics.c | 12 | ||||
-rw-r--r-- | atc/update.c | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/atc/graphics.c b/atc/graphics.c index f95cf0de..e7f64398 100644 --- a/atc/graphics.c +++ b/atc/graphics.c @@ -1,4 +1,4 @@ -/* $NetBSD: graphics.c,v 1.5 1998/11/10 13:43:30 hubertf Exp $ */ +/* $NetBSD: graphics.c,v 1.6 1999/07/24 23:58:15 hubertf Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -50,7 +50,7 @@ #if 0 static char sccsid[] = "@(#)graphics.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: graphics.c,v 1.5 1998/11/10 13:43:30 hubertf Exp $"); +__RCSID("$NetBSD: graphics.c,v 1.6 1999/07/24 23:58:15 hubertf Exp $"); #endif #endif /* not lint */ @@ -401,8 +401,12 @@ loser(p, s) wmove(input, 0, 0); wclrtobot(input); - wprintw(input, "Plane '%c' %s\n\nHit space for top players list...", - name(p), s); + /* p may be NULL if we ran out of memory */ + if (p == NULL) + wprintw(input, "%s\n\nHit space for top players list...", s); + else + wprintw(input, "Plane '%c' %s\n\nHit space for top players list...", + name(p), s); wrefresh(input); fflush(stdout); while ((c = getchar()) != EOF && c != ' ') diff --git a/atc/update.c b/atc/update.c index 41ce78a4..a1b8aa77 100644 --- a/atc/update.c +++ b/atc/update.c @@ -1,4 +1,4 @@ -/* $NetBSD: update.c,v 1.8 1998/11/10 13:43:31 hubertf Exp $ */ +/* $NetBSD: update.c,v 1.9 1999/07/24 23:58:15 hubertf Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -50,7 +50,7 @@ #if 0 static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: update.c,v 1.8 1998/11/10 13:43:31 hubertf Exp $"); +__RCSID("$NetBSD: update.c,v 1.9 1999/07/24 23:58:15 hubertf Exp $"); #endif #endif not lint @@ -365,6 +365,8 @@ addplane() p.plane_no = pnum; pp = newplane(); + if (pp == NULL) + loser(NULL, "Out of memory!"); memcpy(pp, &p, sizeof (p)); if (pp->orig_type == T_AIRPORT) |