0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.0.1759: memory leak from duplicate options

Problem:    Memory leak from duplicate options. (Yegappan Lakshmanan)
Solution:   Don't set the default value twice.
This commit is contained in:
Bram Moolenaar 2018-04-24 20:23:56 +02:00
parent 24a2d7264f
commit 09d1d51df5
2 changed files with 18 additions and 10 deletions

View File

@ -3805,17 +3805,23 @@ set_option_default(
dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
if (flags & P_STRING) if (flags & P_STRING)
{ {
/* Use set_string_option_direct() for local options to handle /* skip 'termkey' and 'termsize, they are duplicates of
* freeing and allocating the value. */ * 'termwinkey' and 'termwinsize' */
if (options[opt_idx].indir != PV_NONE) if (STRCMP(options[opt_idx].fullname, "termkey") != 0
set_string_option_direct(NULL, opt_idx, && STRCMP(options[opt_idx].fullname, "termsize") != 0)
options[opt_idx].def_val[dvi], opt_flags, 0);
else
{ {
if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) /* Use set_string_option_direct() for local options to handle
free_string_option(*(char_u **)(varp)); * freeing and allocating the value. */
*(char_u **)varp = options[opt_idx].def_val[dvi]; if (options[opt_idx].indir != PV_NONE)
options[opt_idx].flags &= ~P_ALLOCED; set_string_option_direct(NULL, opt_idx,
options[opt_idx].def_val[dvi], opt_flags, 0);
else
{
if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
free_string_option(*(char_u **)(varp));
*(char_u **)varp = options[opt_idx].def_val[dvi];
options[opt_idx].flags &= ~P_ALLOCED;
}
} }
} }
else if (flags & P_NUM) else if (flags & P_NUM)

View File

@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1759,
/**/ /**/
1758, 1758,
/**/ /**/