diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-04-24 20:23:56 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-04-24 20:23:56 +0200 |
commit | 09d1d51df5d9b215e583b5bbe36df46afb3db35f (patch) | |
tree | 4f5b7229b86db960f4dd4c33a3c4c8b55eab0b90 | |
parent | 24a2d7264fc2394f69a9a890b34d1f09cf63b14e (diff) | |
download | vim-git-09d1d51df5d9b215e583b5bbe36df46afb3db35f.tar.gz |
patch 8.0.1759: memory leak from duplicate optionsv8.0.1759
Problem: Memory leak from duplicate options. (Yegappan Lakshmanan)
Solution: Don't set the default value twice.
-rw-r--r-- | src/option.c | 26 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/option.c b/src/option.c index aea506647..31aec7e78 100644 --- a/src/option.c +++ b/src/option.c @@ -3805,17 +3805,23 @@ set_option_default( dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; if (flags & P_STRING) { - /* Use set_string_option_direct() for local options to handle - * freeing and allocating the value. */ - if (options[opt_idx].indir != PV_NONE) - set_string_option_direct(NULL, opt_idx, - options[opt_idx].def_val[dvi], opt_flags, 0); - else + /* skip 'termkey' and 'termsize, they are duplicates of + * 'termwinkey' and 'termwinsize' */ + if (STRCMP(options[opt_idx].fullname, "termkey") != 0 + && STRCMP(options[opt_idx].fullname, "termsize") != 0) { - 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; + /* Use set_string_option_direct() for local options to handle + * freeing and allocating the value. */ + if (options[opt_idx].indir != PV_NONE) + 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) diff --git a/src/version.c b/src/version.c index dfd82f997..c25fcf163 100644 --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1759, +/**/ 1758, /**/ 1757, |