Mercurial > vim
diff src/evalvars.c @ 19902:481e8fa158b4 v8.2.0507
patch 8.2.0507: getbufvar() may get the wrong dictionary
Commit: https://github.com/vim/vim/commit/5259275347667a90fb88d8ea74331f88ad68edfc
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 3 18:43:35 2020 +0200
patch 8.2.0507: getbufvar() may get the wrong dictionary
Problem: Getbufvar() may get the wrong dictionary. (David le Blanc)
Solution: Check for empty name. (closes https://github.com/vim/vim/issues/5878)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 03 Apr 2020 18:45:04 +0200 |
parents | 435726a03481 |
children | dcec86d796bc |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -2382,6 +2382,7 @@ find_var(char_u *name, hashtab_T **htp, /* * Find variable "varname" in hashtab "ht" with name "htname". + * When "varname" is empty returns curwin/curtab/etc vars dictionary. * Returns NULL if not found. */ dictitem_T * @@ -3503,8 +3504,12 @@ f_getbufvar(typval_T *argvars, typval_T else { // Look up the variable. - // Let getbufvar({nr}, "") return the "b:" dictionary. - v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', varname, FALSE); + if (*varname == NUL) + // Let getbufvar({nr}, "") return the "b:" dictionary. + v = &buf->b_bufvar; + else + v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', + varname, FALSE); if (v != NULL) { copy_tv(&v->di_tv, rettv);