aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/eval.c12
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--test/old/testdir/test_functions.vim6
-rw-r--r--test/old/testdir/test_listdict.vim2
4 files changed, 18 insertions, 8 deletions
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 "";
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index f94725e1cc..99e511a7a4 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -565,8 +565,8 @@ static void f_call(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
func = (char *)tv_get_string(&argvars[0]);
}
- if (*func == NUL) {
- return; // type error or empty name
+ if (func == NULL || *func == NUL) {
+ return; // type error, empty name or null function
}
dict_T *selfdict = NULL;
@@ -1136,7 +1136,7 @@ static void f_ctxsize(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
/// Set the cursor position.
-/// If 'charcol' is true, then use the column number as a character offset.
+/// If "charcol" is true, then use the column number as a character offset.
/// Otherwise use the column number as a byte offset.
static void set_cursorpos(typval_T *argvars, typval_T *rettv, bool charcol)
{
diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim
index ad2b6dc563..3144af83d7 100644
--- a/test/old/testdir/test_functions.vim
+++ b/test/old/testdir/test_functions.vim
@@ -2009,6 +2009,12 @@ func Test_call()
eval mydict.len->call([], mydict)->assert_equal(4)
call assert_fails("call call('Mylen', [], 0)", 'E715:')
call assert_fails('call foo', 'E107:')
+
+ " This once caused a crash.
+ " Nvim doesn't have null functions
+ " call call(test_null_function(), [])
+ " Nvim doesn't have null partials
+ " call call(test_null_partial(), [])
endfunc
func Test_char2nr()
diff --git a/test/old/testdir/test_listdict.vim b/test/old/testdir/test_listdict.vim
index 41ea04c755..cbed71bb0a 100644
--- a/test/old/testdir/test_listdict.vim
+++ b/test/old/testdir/test_listdict.vim
@@ -751,6 +751,8 @@ func Test_reduce()
" should not crash
" Nvim doesn't have null functions
" call assert_fails('echo reduce([1], test_null_function())', 'E1132:')
+ " Nvim doesn't have null partials
+ " call assert_fails('echo reduce([1], test_null_partial())', 'E1132:')
endfunc
" splitting a string to a List using split()