mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-15 02:11:07 +02:00
43227: fix memory leaks in term{cap,info}.c
This commit is contained in:
parent
96ea5e32b4
commit
ad9f07e66f
4 changed files with 50 additions and 20 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2018-08-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||||
|
|
||||||
|
* 43227: Src/Modules/termcap.c, Src/Modules/terminfo.c,
|
||||||
|
Src/utils.c: fix memory leaks not fixed in 43219
|
||||||
|
|
||||||
2018-07-31 dana <dana@dana.is>
|
2018-07-31 dana <dana@dana.is>
|
||||||
|
|
||||||
* 43207 (tweaked): Completion/Unix/Type/_bind_addresses,
|
* 43207 (tweaked): Completion/Unix/Type/_bind_addresses,
|
||||||
|
|
|
@ -345,16 +345,7 @@ int
|
||||||
boot_(UNUSED(Module m))
|
boot_(UNUSED(Module m))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TGETENT
|
#ifdef HAVE_TGETENT
|
||||||
# ifdef HAVE_SETUPTERM
|
zsetupterm();
|
||||||
int errret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Just because we can't set up the terminal doesn't
|
|
||||||
* mean the modules hasn't booted---TERM may change,
|
|
||||||
* and it should be handled dynamically---so ignore errors here.
|
|
||||||
*/
|
|
||||||
(void)setupterm((char *)0, 1, &errret);
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +354,9 @@ boot_(UNUSED(Module m))
|
||||||
int
|
int
|
||||||
cleanup_(Module m)
|
cleanup_(Module m)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_TGETENT
|
||||||
|
zdeleteterm();
|
||||||
|
#endif
|
||||||
return setfeatureenables(m, &module_features, NULL);
|
return setfeatureenables(m, &module_features, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,16 +338,7 @@ int
|
||||||
boot_(UNUSED(Module m))
|
boot_(UNUSED(Module m))
|
||||||
{
|
{
|
||||||
#ifdef USE_TERMINFO_MODULE
|
#ifdef USE_TERMINFO_MODULE
|
||||||
# ifdef HAVE_SETUPTERM
|
zsetupterm();
|
||||||
int errret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Just because we can't set up the terminal doesn't
|
|
||||||
* mean the modules hasn't booted---TERM may change,
|
|
||||||
* and it should be handled dynamically---so ignore errors here.
|
|
||||||
*/
|
|
||||||
(void)setupterm((char *)0, 1, &errret);
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -357,6 +348,9 @@ boot_(UNUSED(Module m))
|
||||||
int
|
int
|
||||||
cleanup_(Module m)
|
cleanup_(Module m)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_TERMINFO_MODULE
|
||||||
|
zdeleteterm();
|
||||||
|
#endif
|
||||||
return setfeatureenables(m, &module_features, NULL);
|
return setfeatureenables(m, &module_features, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
Src/utils.c
37
Src/utils.c
|
@ -375,6 +375,43 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
|
||||||
fflush(file);
|
fflush(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wrapper for setupterm() and del_curterm().
|
||||||
|
* These are called from terminfo.c and termcap.c.
|
||||||
|
*/
|
||||||
|
static int term_count; /* reference count of cur_term */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
mod_export void
|
||||||
|
zsetupterm(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SETUPTERM
|
||||||
|
int errret;
|
||||||
|
|
||||||
|
DPUTS(term_count < 0 || (term_count > 0 && !cur_term),
|
||||||
|
"inconsistent term_count and/or cur_term");
|
||||||
|
/*
|
||||||
|
* Just because we can't set up the terminal doesn't
|
||||||
|
* mean the modules hasn't booted---TERM may change,
|
||||||
|
* and it should be handled dynamically---so ignore errors here.
|
||||||
|
*/
|
||||||
|
if (term_count++ == 0)
|
||||||
|
(void)setupterm((char *)0, 1, &errret);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
mod_export void
|
||||||
|
zdeleteterm(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SETUPTERM
|
||||||
|
DPUTS(term_count < 1 || !cur_term,
|
||||||
|
"inconsistent term_count and/or cur_term");
|
||||||
|
if (--term_count == 0)
|
||||||
|
del_curterm(cur_term);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Output a single character, for the termcap routines. *
|
/* Output a single character, for the termcap routines. *
|
||||||
* This is used instead of putchar since it can be a macro. */
|
* This is used instead of putchar since it can be a macro. */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue