diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-03 18:43:35 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-03 18:43:35 +0200 |
commit | 5259275347667a90fb88d8ea74331f88ad68edfc (patch) | |
tree | c696583e3850e1c3cf3267bb0f5e88f69e9838e6 /src/evalvars.c | |
parent | d1e9dc272355fe3ab112af5f04b0516b2e9a4fa6 (diff) |
patch 8.2.0507: getbufvar() may get the wrong dictionaryv8.2.0507
Problem: Getbufvar() may get the wrong dictionary. (David le Blanc)
Solution: Check for empty name. (closes #5878)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 7e408864ff..c4bc957fcd 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2382,6 +2382,7 @@ find_var(char_u *name, hashtab_T **htp, int no_autoload) /* * 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 *rettv) 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); |