]> granicus.if.org Git - vim/commitdiff
patch 8.2.4128: crash when method cannot be found v8.2.4128
authorBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 10:37:29 +0000 (10:37 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 18 Jan 2022 10:37:29 +0000 (10:37 +0000)
Problem:    Crash when method cannot be found. (Christian J. Robinson)
Solution:   Don't mix up pointer names.

src/eval.c
src/testdir/test_vim9_expr.vim
src/version.c

index bf65082e275496cb69f182e0a4cd46c5d3a4c301..2b145e1a2a4f2ebc47a55bb2235d0b7455d8c873 100644 (file)
@@ -4050,16 +4050,21 @@ eval_method(
        if (**arg != '(' && alias == NULL
                                    && (paren = vim_strchr(*arg, '(')) != NULL)
        {
+           char_u *deref;
+
            *arg = name;
            *paren = NUL;
-           name = deref_function_name(arg, &tofree, evalarg, verbose);
-           if (name == NULL)
+           deref = deref_function_name(arg, &tofree, evalarg, verbose);
+           if (deref == NULL)
            {
                *arg = name + len;
                ret = FAIL;
            }
            else
+           {
+               name = deref;
                len = STRLEN(name);
+           }
            *paren = '(';
        }
 
index a644e172c48ca22c300f0e079dc7bf185780d116..6428e6386a1a77e95d16f7dcb196def27d37cbe2 100644 (file)
@@ -3214,6 +3214,14 @@ def Test_expr8_method_call_import()
   END
   CheckScriptSuccess(lines)
 
+  lines =<< trim END
+      vim9script
+      import './Xsquare.vim'
+
+      echo range(5)->Xsquare.NoSuchFunc()
+  END
+  CheckScriptFailure(lines, 'E1048: Item not found in script: NoSuchFunc')
+
   delete('Xsquare.vim')
 enddef
 
index cff3cb8d39a7031f94b87628b857442079bbf1a9..af851d3a6a0d2e6aa3a268a1be2a381b1a6994c7 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4128,
 /**/
     4127,
 /**/