[Top][All Lists]

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

setupterm memory leak

From: Usamah Malik
Subject: setupterm memory leak
Date: Thu, 07 May 2009 21:08:42 -0000
User-agent: Opera Mail/9.64 (Linux)

We'd been finding memory leaks (via valgrind) in ncurses. This happens when ncurses is being used from tecla library. The stack is below:

==5125== 46,254 (2,236 direct, 44,018 indirect) bytes in 13 blocks are definitely lost in loss record 43 of 45
==5125==    at 0x400497E: calloc (vg_replace_malloc.c:397)
==5125==    by 0x5386C86: _nc_setupterm (in /usr/lib/libncurses.so.5.7)
==5125==    by 0x53871E2: setupterm (in /usr/lib/libncurses.so.5.7)
==5125==    by 0x825596E: _gl_change_terminal (in .........)

ncurse version: 5.7
platform: linux x86

On deeper analysis of setupterm we found a global variable being assigned chunks of memory at every setupterm call. Applying the following diff to lib_setup.c seems to fix it:

diff ./ncurses/tinfo/lib_setup_old.c ./ncurses/tinfo/lib_setup.c
<       TERMINAL *oldterm = set_curterm(termp);
<       del_curterm(oldterm);

ncurses is some hard-to-read code. So just putting it out here for analysis. Any comments would be appreciated.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]