diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-09-06 20:56:56 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-09-06 20:56:56 +0200 |
commit | ddfc05100a29263a682dd96bb924dfde4354a654 (patch) | |
tree | b30efee7b9f80ea356d3fe9de194888d312e4979 | |
parent | 3b318513561b5862944769188ae4af6b70311838 (diff) | |
download | vim-git-ddfc05100a29263a682dd96bb924dfde4354a654.tar.gz |
patch 8.2.3408: can delete a numbered functionv8.2.3408
Problem: Can delete a numbered function. (Naohiro Ono)
Solution: Disallow deleting a numbered function. (closes #8760)
-rw-r--r-- | src/testdir/test_user_func.vim | 5 | ||||
-rw-r--r-- | src/userfunc.c | 7 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index 747ec486b..819a6bba9 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -434,6 +434,11 @@ func Test_del_func() func d.fn() return 1 endfunc + + " cannot delete the dict function by number + let nr = substitute(execute('echo d'), '.*function(''\(\d\+\)'').*', '\1', '') + call assert_fails('delfunction g:' .. nr, 'E475: Invalid argument: g:') + delfunc d.fn call assert_equal({'a' : 10}, d) endfunc diff --git a/src/userfunc.c b/src/userfunc.c index aa55bc85e..e51df51ff 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -4669,6 +4669,13 @@ ex_delfunction(exarg_T *eap) if (eap->nextcmd != NULL) *p = NUL; + if (isdigit(*name) && fudi.fd_dict == NULL) + { + if (!eap->skip) + semsg(_(e_invarg2), eap->arg); + vim_free(name); + return; + } if (!eap->skip) fp = find_func(name, is_global, NULL); vim_free(name); diff --git a/src/version.c b/src/version.c index 6301d77a8..54533dc91 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3408, +/**/ 3407, /**/ 3406, |