diff options
-rw-r--r-- | src/misc1.c | 12 | ||||
-rw-r--r-- | src/testdir/test_options.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/misc1.c b/src/misc1.c index 951467d94..1a220e1eb 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -9252,6 +9252,7 @@ find_match(int lookfor, linenr_T ourscope) get_expr_indent(void) { int indent; + char_u *inde_copy; pos_T save_pos; colnr_T save_curswant; int save_set_curswant; @@ -9268,7 +9269,16 @@ get_expr_indent(void) if (use_sandbox) ++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. */ + 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) --sandbox; --textlock; diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index d72ca74b2..5d2033a5d 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -319,3 +319,16 @@ func Test_set_values() throw 'Skipped: opt_test.vim does not exist' endif 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 diff --git a/src/version.c b/src/version.c index 28fe0b7e8..60dbdf418 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 575, +/**/ 574, /**/ 573, |