mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06: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
@ -538,7 +538,14 @@ int get_expr_indent(void)
|
|||||||
sandbox++;
|
sandbox++;
|
||||||
}
|
}
|
||||||
textlock++;
|
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) {
|
if (use_sandbox) {
|
||||||
sandbox--;
|
sandbox--;
|
||||||
|
@ -275,3 +275,15 @@ func Test_complete()
|
|||||||
set complete&
|
set complete&
|
||||||
endfun
|
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