Package: netris
Version: 0.52-8
Severity: normal
Tags: patch
Valgrind reports a memory leak in netris:
20 bytes in 1 blocks are definitely lost in loss record 5 of 43
at 0x4023D47: realloc (vg_replace_malloc.c:476)
by 0x804AF7D: GetTermcapInfo (curses.c:152)
by 0x804AD15: InitScreens (curses.c:68)
by 0x804A84C: main (game.c:428)
Fixed by removing hardly needed realloc. I added also an additional check for
malloc returning NULL.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Versions of packages netris depends on:
ii libc6 2.11.2-2 Embedded GNU C Library: Shared lib
ii libncurses5 5.7+20100313-2 shared libraries for terminal hand
netris recommends no packages.
netris suggests no packages.
-- no debconf information
diff -rU 10 netris-0.52//curses.c netris-0.52-fixes//curses.c
--- netris-0.52//curses.c 2003-08-13 03:33:02.000000000 +0200
+++ netris-0.52-fixes//curses.c 2010-07-29 16:42:07.000000000 +0200
@@ -127,36 +127,35 @@
int bufSize = 10240;
if (!(term = getenv("TERM")))
return;
if (tgetent(scratch, term) == 1) {
/*
* Make the buffer HUGE, since tgetstr is unsafe.
* Allocate it on the heap too.
*/
data = buf = malloc(bufSize);
+ if (buf == NULL)
+ fatal("memory allocation error");
/*
* There is no standard include file for tgetstr, no prototype
* definitions. I like casting better than using my own prototypes
* because if I guess the prototype, I might be wrong, especially
* with regards to "const".
*/
term_vi = (char *)tgetstr("vi", &data);
term_ve = (char *)tgetstr("ve", &data);
/* Okay, so I'm paranoid; I just don't like unsafe routines */
if (data > buf + bufSize)
fatal("tgetstr overflow, you must have a very sick termcap");
-
- /* Trim off the unused portion of buffer */
- buf = realloc(buf, data - buf);
}
/*
* If that fails, use hardcoded vt220 codes.
* They don't seem to do anything bad on vt100's, so
* we'll try them just in case they work.
*/
if (!term_vi || !term_ve) {
static char *vts[] = {
"vt100", "vt101", "vt102",