summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorkre <kre@NetBSD.org>2023-04-15 13:00:30 +0000
committerkre <kre@NetBSD.org>2023-04-15 13:00:30 +0000
commit93e49a68a605b32b4afdb8ea703b98244f20eeb8 (patch)
treeabff218533cdf8a08c3be0734cd1a1ca772066ac /games
parent7211b9ad4b3c6fa843ac5bbde7061f5c2d9a3e6b (diff)
Garbage collect "char *mp" - it used to point at memory malloc()'d
to hold the termcap entry, back when worms used termcap rather than curses, and termcap was termcap, rather that a terminfo wannabe. This should have been removed when worms was converted to curses in 1999, but wasn't, so worms has been doing a meaningless malloc(1024) and never using the result, ever since. While here, since the line needed changing anyway to remove mp, change a malloc() of a product into calloc() so it can deal with any possible (admittedly extremely unlikely here) integer overflows. NFCI
Diffstat (limited to 'games')
-rw-r--r--games/worms/worms.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/games/worms/worms.c b/games/worms/worms.c
index 7b63d7bf401..6bafdf462b8 100644
--- a/games/worms/worms.c
+++ b/games/worms/worms.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worms.c,v 1.23 2020/10/14 07:32:53 nia Exp $ */
+/* $NetBSD: worms.c,v 1.24 2023/04/15 13:00:30 kre Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: worms.c,v 1.23 2020/10/14 07:32:53 nia Exp $");
+__RCSID("$NetBSD: worms.c,v 1.24 2023/04/15 13:00:30 kre Exp $");
#endif
#endif /* not lint */
@@ -193,10 +193,8 @@ main(int argc, char *argv[])
int CO, LI, last, bottom, ch, length, number, trail;
short **ref;
const char *field;
- char *mp;
unsigned int delay = 20000;
- mp = NULL;
length = 16;
number = 3;
trail = ' ';
@@ -232,8 +230,7 @@ main(int argc, char *argv[])
exit(1);
}
- if (!(worm = malloc((size_t)number *
- sizeof(struct worm))) || !(mp = malloc((size_t)1024)))
+ if (!(worm = calloc((size_t)number, sizeof(struct worm))))
nomem();
if (!initscr())
errx(0, "couldn't initialize screen");