diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-16 00:12:50 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-16 00:37:37 -0400 |
commit | 9ab6fe4fedd5655c6568ace8b853fbfd078107ea (patch) | |
tree | 47958b03526797b41b486cf107601c4ff4e07e55 | |
parent | c990d65c37ded9ad9f4002a6eb6ec36aa29b4fe3 (diff) | |
download | rneovim-9ab6fe4fedd5655c6568ace8b853fbfd078107ea.tar.gz rneovim-9ab6fe4fedd5655c6568ace8b853fbfd078107ea.tar.bz2 rneovim-9ab6fe4fedd5655c6568ace8b853fbfd078107ea.zip |
vim-patch:8.0.0575: using freed memory when resetting 'indentexpr'
Problem: Using freed memory when resetting 'indentexpr' while evaluating
it. (Dominique Pelle)
Solution: Make a copy of 'indentexpr'.
https://github.com/vim/vim/commit/a701b3b6f0f06ac0c9fcc75c6c34a1258fc3b1a2
-rw-r--r-- | src/nvim/indent.c | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_options.vim | 12 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c index efca739c2d..0d5b82bc5b 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -538,7 +538,14 @@ int get_expr_indent(void) sandbox++; } textlock++; - indent = (int)eval_to_number(curbuf->b_p_inde); + + // Need to make a copy, the 'indentexpr' option could be changed while + // evaluating it. + char_u *inde_copy = vim_strsave(curbuf->b_p_inde); + if (inde_copy != NULL) { + indent = (int)eval_to_number(inde_copy); + xfree(inde_copy); + } if (use_sandbox) { sandbox--; diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 5ae8528ee9..d9cd5fd583 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -275,3 +275,15 @@ func Test_complete() set complete& endfun +func ResetIndentexpr() + set indentexpr= +endfunc + +func Test_set_indentexpr() + " this was causing usage of freed memory + set indentexpr=ResetIndentexpr() + new + call feedkeys("i\<c-f>", 'x') + call assert_equal('', &indentexpr) + bwipe! +endfunc |