1
0
forked from aniani/vim

patch 8.2.4139: using freed memory in expression abbreviation

Problem:    Using freed memory if an expression abbreviation deletes the
            abbreviation.
Solution:   Do not access the pointer after evaluating the expression.
This commit is contained in:
Bram Moolenaar
2022-01-18 20:30:39 +00:00
parent ef7aadbe36
commit 94075b2b0e
3 changed files with 33 additions and 6 deletions

View File

@@ -704,6 +704,11 @@ func Test_mapcomplete()
mapclear
endfunc
func GetAbbrText()
unabbr hola
return 'hello'
endfunc
" Test for <expr> in abbreviation
func Test_expr_abbr()
new
@@ -719,7 +724,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