[slang-users] Memory leak in SLtt_get_terminfo
Miroslav Lichvar
mlichvar at redhat.com
Tue May 15 10:46:23 EDT 2007
Hi,
a memory leak occurs when SLtt_get_terminfo function is called
repeatedly as data allocated in _pSLtt_tigetent are lost.
Attached is a patch that deletes the old entry when a new entry is
requested, that should at least keep the size of the leak constant.
--
Miroslav Lichvar
-------------- next part --------------
Index: src/sldisply.c
===================================================================
--- src/sldisply.c (revision 116)
+++ src/sldisply.c (working copy)
@@ -2374,6 +2374,8 @@
|| !strcmp (term, "screen"));
# ifndef USE_TERMCAP
+ if (NULL != Terminfo)
+ _pSLtt_tifreeent (Terminfo);
if (NULL == (Terminfo = _pSLtt_tigetent (term)))
{
if (almost_vtxxx) /* Special cases. */
Index: src/sltermin.c
===================================================================
--- src/sltermin.c (revision 116)
+++ src/sltermin.c (working copy)
@@ -347,6 +347,16 @@
return NULL;
}
+void _pSLtt_tifreeent (SLterminfo_Type *t)
+{
+ SLfree ((char *)t->string_table);
+ SLfree ((char *)t->string_offsets);
+ SLfree ((char *)t->numbers);
+ SLfree ((char *)t->boolean_flags);
+ SLfree ((char *)t->terminal_names);
+ SLfree ((char *)t);
+}
+
#ifdef SLANG_UNTIC
# define UNTIC_COMMENT(x) ,x
#else
More information about the slang-users-l
mailing list