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 /snake | |
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 'snake')
-rw-r--r-- | snake/snscore/snscore.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/snake/snscore/snscore.c b/snake/snscore/snscore.c index b5f57cf3..e50fed75 100644 --- a/snake/snscore/snscore.c +++ b/snake/snscore/snscore.c @@ -1,4 +1,4 @@ -/* $NetBSD: snscore.c,v 1.9 1999/09/08 21:18:00 jsm Exp $ */ +/* $NetBSD: snscore.c,v 1.10 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[] = "@(#)snscore.c 8.1 (Berkeley) 7/19/93"; #else -__RCSID("$NetBSD: snscore.c,v 1.9 1999/09/08 21:18:00 jsm Exp $"); +__RCSID("$NetBSD: snscore.c,v 1.10 1999/09/09 17:28:00 jsm Exp $"); #endif #endif /* not lint */ @@ -98,8 +98,9 @@ main() if (p == NULL) continue; q = p -> pw_name; - players[noplayers].name = malloc(strlen(q) + 1); - strcpy(players[noplayers].name, q); + players[noplayers].name = strdup(q); + if (players[noplayers].name == NULL) + errx(1, "out of memory"); noplayers++; } } |