aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-10-06 02:24:16 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 22:01:12 +0300
commit3a4a9418853338c3a0e00358b411186b5723184a (patch)
tree01ecfbbbaf4a7981472d0255c149fd56aef7aa80 /src
parent937f6584d7210d6d342626e59b14d27794d3314f (diff)
downloadrneovim-3a4a9418853338c3a0e00358b411186b5723184a.tar.gz
rneovim-3a4a9418853338c3a0e00358b411186b5723184a.tar.bz2
rneovim-3a4a9418853338c3a0e00358b411186b5723184a.zip
shada: Fix memory leak and double free when setting both &vi and &sd
Diffstat (limited to 'src')
-rw-r--r--src/nvim/option.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 653b217485..cbb22a0546 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1968,6 +1968,8 @@ static void redraw_titles(void) {
redraw_tabline = TRUE;
}
+static int shada_idx = -1;
+
/*
* Set a string option to a new value (without checking the effect).
* The string is copied into allocated memory.
@@ -2001,6 +2003,8 @@ set_string_option_direct (
if (options[idx].var == NULL) /* can't set hidden option */
return;
+ assert((void *) options[idx].var != (void *) &p_shada);
+
s = vim_strsave(val);
{
varp = (char_u **)get_varp_scope(&(options[idx]),
@@ -2443,6 +2447,13 @@ did_set_string_option (
errmsg = e_invarg;
/* 'shada' */
} else if (varp == &p_shada) {
+ // TODO(ZyX-I): Remove this code in the future, alongside with &viminfo
+ // option.
+ opt_idx = ((options[opt_idx].fullname[0] == 'v')
+ ? (shada_idx == -1
+ ? ((shada_idx = findoption((char_u *) "shada")))
+ : shada_idx)
+ : opt_idx);
for (s = p_shada; *s; ) {
/* Check it's a valid character */
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {