mirror of
https://github.com/vim/vim.git
synced 2025-10-06 05:44:14 -04:00
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'.
This commit is contained in:
12
src/misc1.c
12
src/misc1.c
@@ -9252,6 +9252,7 @@ find_match(int lookfor, linenr_T ourscope)
|
|||||||
get_expr_indent(void)
|
get_expr_indent(void)
|
||||||
{
|
{
|
||||||
int indent;
|
int indent;
|
||||||
|
char_u *inde_copy;
|
||||||
pos_T save_pos;
|
pos_T save_pos;
|
||||||
colnr_T save_curswant;
|
colnr_T save_curswant;
|
||||||
int save_set_curswant;
|
int save_set_curswant;
|
||||||
@@ -9268,7 +9269,16 @@ get_expr_indent(void)
|
|||||||
if (use_sandbox)
|
if (use_sandbox)
|
||||||
++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. */
|
||||||
|
inde_copy = vim_strsave(curbuf->b_p_inde);
|
||||||
|
if (inde_copy != NULL)
|
||||||
|
{
|
||||||
|
indent = (int)eval_to_number(inde_copy);
|
||||||
|
vim_free(inde_copy);
|
||||||
|
}
|
||||||
|
|
||||||
if (use_sandbox)
|
if (use_sandbox)
|
||||||
--sandbox;
|
--sandbox;
|
||||||
--textlock;
|
--textlock;
|
||||||
|
@@ -319,3 +319,16 @@ func Test_set_values()
|
|||||||
throw 'Skipped: opt_test.vim does not exist'
|
throw 'Skipped: opt_test.vim does not exist'
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
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
|
||||||
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
575,
|
||||||
/**/
|
/**/
|
||||||
574,
|
574,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user