Module Name: src
Committed By: kre
Date: Sat Apr 15 13:00:30 UTC 2023
Modified Files:
src/games/worms: worms.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/games/worms/worms.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/worms/worms.c
diff -u src/games/worms/worms.c:1.23 src/games/worms/worms.c:1.24
--- src/games/worms/worms.c:1.23 Wed Oct 14 07:32:53 2020
+++ src/games/worms/worms.c Sat Apr 15 13:00:30 2023
@@ -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, 19
#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");