summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Pelle <dominique.pelle@gmail.com>2021-05-13 14:55:55 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-13 14:55:55 +0200
commitfe8ebdbe5c4e116311c0c0d5937b89ded5c92d01 (patch)
tree28e14ae8bf2b71dcbe7e3cc83c56657be306ba54
parent588cf7547bafaff46a82bc125d05d24a1cedf827 (diff)
patch 8.2.2848: crash whn calling partialv8.2.2848
Problem: Crash whn calling partial. Solution: Check for NULL pointer. (Dominique Pellé, closes #8202)
-rw-r--r--src/eval.c11
-rw-r--r--src/evalfunc.c8
-rw-r--r--src/testdir/test_functions.vim4
-rw-r--r--src/testdir/test_listdict.vim1
-rw-r--r--src/version.c2
5 files changed, 18 insertions, 8 deletions
diff --git a/src/eval.c b/src/eval.c
index aa3d0a1ec8..0d4f5fe59c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -4284,10 +4284,13 @@ eval_index_inner(
char_u *
partial_name(partial_T *pt)
{
- 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 (char_u *)"";
}
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 6a2244961e..e740f91b13 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1971,7 +1971,7 @@ internal_func_name(int idx)
}
/*
- * Check the argument types for builting function "idx".
+ * Check the argument types for builtin function "idx".
* Uses the list of types on the type stack: "types".
* Return FAIL and gives an error message when a type is wrong.
*/
@@ -2475,8 +2475,8 @@ f_call(typval_T *argvars, typval_T *rettv)
}
else
func = 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
if (argvars[2].v_type != VAR_UNKNOWN)
{
@@ -2779,7 +2779,7 @@ f_cosh(typval_T *argvars, typval_T *rettv)
/*
* Set the cursor position.
- * If 'charcol' is TRUE, then use the column number as a character offet.
+ * If 'charcol' is TRUE, then use the column number as a character offset.
* Otherwise use the column number as a byte offset.
*/
static void
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 936a2d0609..f675697772 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2150,6 +2150,10 @@ 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.
+ call call(test_null_function(), [])
+ call call(test_null_partial(), [])
endfunc
func Test_char2nr()
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 1b0796d816..601dd17e5e 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -743,6 +743,7 @@ func Test_reduce()
" should not crash
call assert_fails('echo reduce([1], test_null_function())', 'E1132:')
+ call assert_fails('echo reduce([1], test_null_partial())', 'E1132:')
endfunc
" splitting a string to a List using split()
diff --git a/src/version.c b/src/version.c
index f1f2a1cc2e..3fdb588358 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2848,
+/**/
2847,
/**/
2846,