To: vim_dev@googlegroups.com Subject: Patch 8.0.1759 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1759 Problem: Memory leak from duplicate options. (Yegappan Lakshmanan) Solution: Don't set the default value twice. Files: src/option.c *** ../vim-8.0.1758/src/option.c 2018-04-21 20:02:32.734539968 +0200 --- src/option.c 2018-04-24 20:19:02.251695218 +0200 *************** *** 3805,3821 **** 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; } } else if (flags & P_NUM) --- 3805,3827 ---- dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; if (flags & P_STRING) { ! /* 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) *** ../vim-8.0.1758/src/version.c 2018-04-24 19:36:37.504162815 +0200 --- src/version.c 2018-04-24 20:23:10.745916829 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1759, /**/ -- This sentence is not sure that it exists, but if it does, it will certainly consider the possibility that other sentences exist. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///