From 9be24110f68abc111c87c88d82f50f64a1d3ecdd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Dec 2022 16:32:50 +0800 Subject: 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 --- src/nvim/testdir/test_mapping.vim | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_mapping.vim') 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 in abbreviation func Test_expr_abbr() new @@ -782,7 +787,14 @@ func Test_expr_abbr() call assert_equal('', getline(1)) unabbr hte - close! + " evaluating the expression deletes the abbreviation + abbr hola GetAbbrText() + call assert_equal('GetAbbrText()', maparg('hola', 'i', '1')) + call feedkeys("ahola \", '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 -- cgit