Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/atc This patch makes atc(6) check for memory allocatio...



details:   https://anonhg.NetBSD.org/src/rev/a2695e5b9a26
branches:  trunk
changeset: 474879:a2695e5b9a26
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Sat Jul 24 23:58:15 1999 +0000

description:
This patch makes atc(6) check for memory allocation failure.

Patch submitted by Joseph Myers <jsm28%cam.ac.uk@localhost> in PR 8056,
with small enhancement to make clearer when loser() is called
with NULL.

diffstat:

 games/atc/graphics.c |  12 ++++++++----
 games/atc/update.c   |   6 ++++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diffs (60 lines):

diff -r 178497c52169 -r a2695e5b9a26 games/atc/graphics.c
--- a/games/atc/graphics.c      Sat Jul 24 15:50:44 1999 +0000
+++ b/games/atc/graphics.c      Sat Jul 24 23:58:15 1999 +0000
@@ -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 @@
 
        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 -r 178497c52169 -r a2695e5b9a26 games/atc/update.c
--- a/games/atc/update.c        Sat Jul 24 15:50:44 1999 +0000
+++ b/games/atc/update.c        Sat Jul 24 23:58:15 1999 +0000
@@ -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 @@
        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)



Home | Main Index | Thread Index | Old Index