From 572627255983b7733b6ad05da52b3e704aae8a2f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 3 Apr 2020 20:36:11 -0400 Subject: vim-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 vim/vim#5878) https://github.com/vim/vim/commit/5259275347667a90fb88d8ea74331f88ad68edfc --- src/nvim/eval/funcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 8f16855d0b..21a6904674 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2831,8 +2831,10 @@ static void f_getbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else { // Look up the variable. // Let getbufvar({nr}, "") return the "b:" dictionary. - dictitem_T *const v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', - varname, strlen(varname), false); + dictitem_T *const v = *varname == NUL + ? (dictitem_T *)&buf->b_bufvar + : find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', + varname, strlen(varname), false); if (v != NULL) { tv_copy(&v->di_tv, rettv); done = true; -- cgit