mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
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'.
a701b3b6f0
This commit is contained in:
parent
c990d65c37
commit
9ab6fe4fed
src/nvim
@ -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--;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user