aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_mapping.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-24 16:32:50 +0800
committerGitHub <noreply@github.com>2022-12-24 16:32:50 +0800
commit9be24110f68abc111c87c88d82f50f64a1d3ecdd (patch)
treed8fb658a64bd9099e3b4b128eac04c496c3a9896 /src/nvim/testdir/test_mapping.vim
parent4d4e697ef0cc0cd4a95acbbdc22074adb537a5bf (diff)
downloadrneovim-9be24110f68abc111c87c88d82f50f64a1d3ecdd.tar.gz
rneovim-9be24110f68abc111c87c88d82f50f64a1d3ecdd.tar.bz2
rneovim-9be24110f68abc111c87c88d82f50f64a1d3ecdd.zip
vim-patch:8.2.4139: using freed memory in expression abbreviation (#21522)
Problem: Using freed memory if an expression abbreviation deletes the abbreviation. Solution: Do not access the pointer after evaluating the expression. https://github.com/vim/vim/commit/94075b2b0e8e3b75334799d2c082497fbf85ffa1 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/testdir/test_mapping.vim')
-rw-r--r--src/nvim/testdir/test_mapping.vim14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index 522a51589f..5c5a65d4ca 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -767,6 +767,11 @@ func Test_mapcomplete()
mapclear
endfunc
+func GetAbbrText()
+ unabbr hola
+ return 'hello'
+endfunc
+
" Test for <expr> in abbreviation
func Test_expr_abbr()
new
@@ -782,7 +787,14 @@ func Test_expr_abbr()
call assert_equal('', getline(1))
unabbr <expr> hte
- close!
+ " evaluating the expression deletes the abbreviation
+ abbr <expr> hola GetAbbrText()
+ call assert_equal('GetAbbrText()', maparg('hola', 'i', '1'))
+ call feedkeys("ahola \<Esc>", 'xt')
+ call assert_equal('hello ', getline('.'))
+ call assert_equal('', maparg('hola', 'i', '1'))
+
+ bwipe!
endfunc
" Test for storing mappings in different modes in a vimrc file