1
0
forked from aniani/vim

patch 8.0.1115: crash when using foldtextresult() recursively

Problem:    Crash when using foldtextresult() recursively.
Solution:   Avoid recursive calls. (Yasuhiro Matsumoto, closes #2098)
This commit is contained in:
Bram Moolenaar
2017-09-16 17:19:22 +02:00
parent 4cf56bbc85
commit 495b7dd213
3 changed files with 23 additions and 0 deletions

View File

@@ -3642,11 +3642,16 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv)
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 UNUSED, typval_T *rettv)
text = vim_strsave(text);
rettv->vval.v_string = text;
}
entered = FALSE;
#endif
}