]> granicus.if.org Git - vim/commitdiff
patch 8.2.2848: crash whn calling partial v8.2.2848
authorDominique Pelle <dominique.pelle@gmail.com>
Thu, 13 May 2021 12:55:55 +0000 (14:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 13 May 2021 12:55:55 +0000 (14:55 +0200)
Problem:    Crash whn calling partial.
Solution:   Check for NULL pointer. (Dominique PellĂ©, closes #8202)

src/eval.c
src/evalfunc.c
src/testdir/test_functions.vim
src/testdir/test_listdict.vim
src/version.c

index aa3d0a1ec8790aeaa4835858ba9618e8fb82200c..0d4f5fe59c729c8edaa58dc0bb12539fa72f8f92 100644 (file)
@@ -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 *)"";
 }
 
index 6a2244961e98a81b995c30402f40fc76a986590f..e740f91b1332a584e1fbdec9a2d18adf70a74e32 100644 (file)
@@ -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
index 936a2d06090071ef851e26b39c0a595dad1e4a15..f675697772ed3804c6ead2d26e6657f350deaf72 100644 (file)
@@ -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()
index 1b0796d81608ae4442368283489aacc85db3f769..601dd17e5e399cada4f924f720233bf488afc573 100644 (file)
@@ -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()
index f1f2a1cc2ed079e33325251262cf42f8b499dccc..3fdb58835861662d90296a4d890653ed96e43ee7 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2848,
 /**/
     2847,
 /**/