From 08121ef69f47f8ad8f8903a732920412e24d30c1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 08:55:42 +0800 Subject: vim-patch:8.2.2848: crash whn calling partial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Crash whn calling partial. Solution: Check for NULL pointer. (Dominique Pellé, closes vim/vim#8202) https://github.com/vim/vim/commit/fe8ebdbe5c4e116311c0c0d5937b89ded5c92d01 Co-authored-by: Dominique Pelle --- src/nvim/eval.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 97cf0c6364..87633365b6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4175,11 +4175,13 @@ int eval_interp_string(char **arg, typval_T *rettv, bool evaluate) char *partial_name(partial_T *pt) FUNC_ATTR_PURE { - if (pt->pt_name != NULL) { - return pt->pt_name; - } - if (pt->pt_func != NULL) { - return pt->pt_func->uf_name; + if (pt != NULL) { + if (pt->pt_name != NULL) { + return pt->pt_name; + } + if (pt->pt_func != NULL) { + return pt->pt_func->uf_name; + } } return ""; } -- cgit From f4d3e279e861dc37dd047c81a0807767a74d251b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 09:01:33 +0800 Subject: vim-patch:8.2.2977: crash when using a null function reference Problem: Crash when using a null function reference. (Naohiro Ono) Solution: Check for an invalid function name. (closes vim/vim#8367) https://github.com/vim/vim/commit/22db0d549f64aa3d8a6e366b70eb8d7e66933b82 Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 87633365b6..a5c81666c1 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -96,6 +96,7 @@ static const char *e_string_list_or_blob_required = N_("E1098: String, List or B static const char e_expression_too_recursive_str[] = N_("E1169: Expression too recursive: %s"); static const char e_dot_can_only_be_used_on_dictionary_str[] = N_("E1203: Dot can only be used on a dictionary: %s"); +static const char e_empty_function_name[] = N_("E1192: Empty function name"); static char * const namespace_char = "abglstvw"; @@ -3273,6 +3274,10 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T funcname = is_lua ? lua_funcname : partial_name(pt); } else { funcname = functv.vval.v_string; + if (funcname == NULL || *funcname == NUL) { + emsg(_(e_empty_function_name)); + goto theend; + } } } else { funcname = ""; @@ -3288,6 +3293,7 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T const int ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, arg, evalarg, &funcexe); +theend: // Clear the funcref afterwards, so that deleting it while // evaluating the arguments is possible (see test55). if (evaluate) { -- cgit From 2e8cec5f2bf2dd1209052e870d9713a932dc7bfa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 09:07:03 +0800 Subject: vim-patch:8.2.2978: warning for uninitialized variable Problem: Warning for uninitialized variable. Solution: Set return value to FAIL. https://github.com/vim/vim/commit/744aecf8777e86fac6d30f072e90e2de353b8ea1 Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a5c81666c1..1d9061186a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3261,6 +3261,7 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T typval_T functv; const char *funcname; bool is_lua = false; + int ret; // need to copy the funcref so that we can clear rettv if (evaluate) { @@ -3276,6 +3277,7 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T funcname = functv.vval.v_string; if (funcname == NULL || *funcname == NUL) { emsg(_(e_empty_function_name)); + ret = FAIL; goto theend; } } @@ -3290,8 +3292,8 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T funcexe.fe_partial = pt; funcexe.fe_selfdict = selfdict; funcexe.fe_basetv = basetv; - const int ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, - arg, evalarg, &funcexe); + ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, + arg, evalarg, &funcexe); theend: // Clear the funcref afterwards, so that deleting it while -- cgit From 68ca16c376bd8786ffc0c7ce7619b9a0ce5657e8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 08:54:07 +0800 Subject: vim-patch:8.2.3783: confusing error for using a variable as a function Problem: Confusing error for using a variable as a function. Solution: If a function is not found but there is a variable, give a more useful error. (issue vim/vim#9310) https://github.com/vim/vim/commit/2ef9156b4284e4a52613c36e3d4667245273a28d Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1d9061186a..b8daa78c79 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2220,6 +2220,7 @@ static int eval_func(char **const arg, evalarg_T *const evalarg, char *const nam const bool evaluate = flags & EVAL_EVALUATE; char *s = name; int len = name_len; + bool found_var = false; if (!evaluate) { check_vars(s, (size_t)len); @@ -2228,7 +2229,7 @@ static int eval_func(char **const arg, evalarg_T *const evalarg, char *const nam // If "s" is the name of a variable of type VAR_FUNC // use its contents. partial_T *partial; - s = deref_func_name(s, &len, &partial, !evaluate); + s = deref_func_name(s, &len, &partial, !evaluate, &found_var); // Need to make a copy, in case evaluating the arguments makes // the name invalid. @@ -2241,6 +2242,7 @@ static int eval_func(char **const arg, evalarg_T *const evalarg, char *const nam funcexe.fe_evaluate = evaluate; funcexe.fe_partial = partial; funcexe.fe_basetv = basetv; + funcexe.fe_found_var = found_var; int ret = get_func_tv(s, len, rettv, arg, evalarg, &funcexe); xfree(s); -- cgit