diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-06-12 01:41:12 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-12 01:41:12 -0400 |
commit | bbd75cee82b64796c040b67b3f251a066049e3da (patch) | |
tree | bc0cafef559cbce8147da7a16ed4f0f212b6a62a /src/nvim/option.c | |
parent | f39fd5b4c424cc477a168fbf4eebfe315d23e614 (diff) | |
parent | 70f28d938c4ebd01c86f7eefbc5ea991014496e8 (diff) | |
download | rneovim-bbd75cee82b64796c040b67b3f251a066049e3da.tar.gz rneovim-bbd75cee82b64796c040b67b3f251a066049e3da.tar.bz2 rneovim-bbd75cee82b64796c040b67b3f251a066049e3da.zip |
Merge #804 'Coverity fix resource leaks 1b'
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 37a5a61d43..6b820ea1ba 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2216,21 +2216,20 @@ set_options_default ( win_comp_scroll(wp); } -/* - * Set the Vi-default value of a string option. - * Used for 'sh', 'backupskip' and 'term'. - */ -void set_string_default(char *name, char_u *val) +/// Set the Vi-default value of a string option. +/// Used for 'sh', 'backupskip' and 'term'. +/// +/// @param name The name of the option +/// @param val The value of the option +void set_string_default(const char *name, const char_u *val) { - char_u *p; - int opt_idx; - - p = vim_strsave(val); - opt_idx = findoption((char_u *)name); + int opt_idx = findoption((char_u *)name); if (opt_idx >= 0) { - if (options[opt_idx].flags & P_DEF_ALLOCED) + if (options[opt_idx].flags & P_DEF_ALLOCED) { free(options[opt_idx].def_val[VI_DEFAULT]); - options[opt_idx].def_val[VI_DEFAULT] = p; + } + + options[opt_idx].def_val[VI_DEFAULT] = (char_u *) xstrdup((char *) val); options[opt_idx].flags |= P_DEF_ALLOCED; } } |