summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-02-25 14:59:34 +0100
committerBram Moolenaar <Bram@vim.org>2017-02-25 14:59:34 +0100
commit95c526e1f6d76acafee4b21f5701d6d6ac8c4b5f (patch)
treebd5c3b788fbd7995938325c97c3ff4c2d72b9b94 /src/buffer.c
parentd3f78dc9ebd729475a7f24a50a91112e300d5ac9 (diff)
downloadvim-95c526e1f6d76acafee4b21f5701d6d6ac8c4b5f.zip
patch 8.0.0365: might free a dict item that wasn't allocated
Problem: Might free a dict item that wasn't allocated. Solution: Call dictitem_free(). (Nikolai Pavlov) Use this for b:changedtick.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/buffer.c b/src/buffer.c
index b394d8e6c..73af50a7a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -832,7 +832,6 @@ free_buffer(buf_T *buf)
free_buffer_stuff(buf, TRUE);
#ifdef FEAT_EVAL
unref_var_dict(buf->b_vars);
- buf->b_changedtick = &buf->b_ct_val;
#endif
#ifdef FEAT_LUA
lua_buffer_free(buf);
@@ -874,31 +873,20 @@ free_buffer(buf_T *buf)
}
/*
- * Initializes buf->b_changedtick.
+ * Initializes b:changedtick.
*/
static void
init_changedtick(buf_T *buf)
{
-#ifdef FEAT_EVAL
- dictitem_T *di = dictitem_alloc((char_u *)"changedtick");
+ dictitem_T *di = (dictitem_T *)&buf->b_ct_di;
- if (di != NULL)
- {
- di->di_flags |= DI_FLAGS_FIX | DI_FLAGS_RO;
- di->di_tv.v_type = VAR_NUMBER;
- di->di_tv.v_lock = VAR_FIXED;
- di->di_tv.vval.v_number = 0;
- if (dict_add(buf->b_vars, di) == OK)
- buf->b_changedtick = &di->di_tv.vval.v_number;
- else
- {
- vim_free(di);
- buf->b_changedtick = &buf->b_ct_val;
- }
- }
- else
-#endif
- buf->b_changedtick = &buf->b_ct_val;
+ di->di_flags = DI_FLAGS_FIX | DI_FLAGS_RO;
+ di->di_tv.v_type = VAR_NUMBER;
+ di->di_tv.v_lock = VAR_FIXED;
+ di->di_tv.vval.v_number = 0;
+
+ STRCPY(buf->b_ct_di.di_key, "changedtick");
+ (void)dict_add(buf->b_vars, di);
}
/*
@@ -919,12 +907,12 @@ free_buffer_stuff(
}
#ifdef FEAT_EVAL
{
- varnumber_T tick = *buf->b_changedtick;
+ varnumber_T tick = CHANGEDTICK(buf);
vars_clear(&buf->b_vars->dv_hashtab); /* free all buffer variables */
hash_init(&buf->b_vars->dv_hashtab);
init_changedtick(buf);
- *buf->b_changedtick = tick;
+ CHANGEDTICK(buf) = tick;
}
#endif
#ifdef FEAT_USR_CMDS