diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-18 10:37:29 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-18 10:37:29 +0000 |
commit | 64283d5e1f5487e2dbaa17d478e6eae040daa064 (patch) | |
tree | 16ed445ad7f02151bf9b6bc19e64c7434169d511 | |
parent | 78f60322f70ab91a32e572fbf3d97c792acbc83a (diff) | |
download | vim-git-64283d5e1f5487e2dbaa17d478e6eae040daa064.tar.gz |
patch 8.2.4128: crash when method cannot be foundv8.2.4128
Problem: Crash when method cannot be found. (Christian J. Robinson)
Solution: Don't mix up pointer names.
-rw-r--r-- | src/eval.c | 9 | ||||
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c index bf65082e2..2b145e1a2 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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 = '('; } diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index a644e172c..6428e6386 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -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 diff --git a/src/version.c b/src/version.c index cff3cb8d3..af851d3a6 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 */ /**/ + 4128, +/**/ 4127, /**/ 4126, |