Mercurial > vim
changeset 13774:d43718b4e232 v8.0.1759
patch 8.0.1759: memory leak from duplicate options
commit https://github.com/vim/vim/commit/09d1d51df5d9b215e583b5bbe36df46afb3db35f
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 24 20:23:56 2018 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 24 Apr 2018 20:30:08 +0200 |
parents | 34fcf913ca26 |
children | d42882beaa18 |
files | src/option.c src/version.c |
diffstat | 2 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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 - { - 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; + /* 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) + { + /* 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)