From 429fa85392a934b34ba7b394558900cbb8786454 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 15 Apr 2013 12:27:36 +0200 Subject: updated for version 7.3.893 Problem: Crash when using b:, w: or t: after closing the buffer, window or tabpage. Solution: Allocate the dictionary instead of having it part of the buffer/window/tabpage struct. (Yukihiro Nakadaira) --- src/buffer.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 2a9fe4d123..5ee6299901 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -648,6 +648,9 @@ free_buffer(buf) buf_T *buf; { free_buffer_stuff(buf, TRUE); +#ifdef FEAT_EVAL + unref_var_dict(buf->b_vars); +#endif #ifdef FEAT_LUA lua_buffer_free(buf); #endif @@ -689,8 +692,8 @@ free_buffer_stuff(buf, free_options) #endif } #ifdef FEAT_EVAL - vars_clear(&buf->b_vars.dv_hashtab); /* free all internal variables */ - hash_init(&buf->b_vars.dv_hashtab); + vars_clear(&buf->b_vars->dv_hashtab); /* free all internal variables */ + hash_init(&buf->b_vars->dv_hashtab); #endif #ifdef FEAT_USR_CMDS uc_clear(&buf->b_ucmds); /* clear local user commands */ @@ -1694,6 +1697,17 @@ buflist_new(ffname, sfname, lnum, flags) vim_free(ffname); return NULL; } +#ifdef FEAT_EVAL + /* init b: variables */ + buf->b_vars = dict_alloc(); + if (buf->b_vars == NULL) + { + vim_free(ffname); + vim_free(buf); + return NULL; + } + init_var_dict(buf->b_vars, &buf->b_bufvar, VAR_SCOPE); +#endif } if (ffname != NULL) @@ -1778,10 +1792,6 @@ buflist_new(ffname, sfname, lnum, flags) buf->b_wininfo->wi_fpos.lnum = lnum; buf->b_wininfo->wi_win = curwin; -#ifdef FEAT_EVAL - /* init b: variables */ - init_var_dict(&buf->b_vars, &buf->b_bufvar, VAR_SCOPE); -#endif #ifdef FEAT_SYN_HL hash_init(&buf->b_s.b_keywtab); hash_init(&buf->b_s.b_keywtab_ic); -- cgit v1.2.3