Mercurial > vim
diff src/evalfunc.c @ 12471:f6534b99b76f v8.0.1115
patch 8.0.1115: crash when using foldtextresult() recursively
commit https://github.com/vim/vim/commit/495b7dd213e096361e6f15e7aed313c1d63d9d3e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 16 17:19:22 2017 +0200
patch 8.0.1115: crash when using foldtextresult() recursively
Problem: Crash when using foldtextresult() recursively.
Solution: Avoid recursive calls. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/2098)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 16 Sep 2017 17:30:04 +0200 |
parents | dfb8254aa735 |
children | 68d7bc045dbe |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3642,11 +3642,16 @@ f_foldtextresult(typval_T *argvars UNUSE char_u buf[FOLD_TEXT_LEN]; foldinfo_T foldinfo; int fold_count; + static int entered = FALSE; #endif rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; #ifdef FEAT_FOLDING + if (entered) + return; /* reject recursive use */ + entered = TRUE; + lnum = get_tv_lnum(argvars); /* treat illegal types and illegal string values for {lnum} the same */ if (lnum < 0) @@ -3660,6 +3665,8 @@ f_foldtextresult(typval_T *argvars UNUSE text = vim_strsave(text); rettv->vval.v_string = text; } + + entered = FALSE; #endif }