ex_getln: Check prev_prompt_errors before running redrawcmdline

Otherwise there will be infinite recursion and shortly a crash. Running 
redrawcmdline recursively occurs under color_cmdline_error label.
This commit is contained in:
ZyX
2017-07-18 00:20:21 +03:00
parent cfb1d937a6
commit 8a581b918b
2 changed files with 22 additions and 6 deletions

View File

@@ -2364,6 +2364,12 @@ static bool color_cmdline(void)
bool dgc_ret = true;
bool tl_ret = true;
if (ccline.prompt_id != prev_prompt_id) {
prev_prompt_errors = 0;
prev_prompt_id = ccline.prompt_id;
} else if (prev_prompt_errors >= MAX_CB_ERRORS) {
goto color_cmdline_end;
}
if (ccline.highlight_callback.type != kCallbackNone) {
// Currently this should only happen while processing input() prompts.
assert(ccline.input_fn);
@@ -2392,12 +2398,6 @@ static bool color_cmdline(void)
if (color_cb.type == kCallbackNone) {
goto color_cmdline_end;
}
if (ccline.prompt_id != prev_prompt_id) {
prev_prompt_errors = 0;
prev_prompt_id = ccline.prompt_id;
} else if (prev_prompt_errors >= MAX_CB_ERRORS) {
goto color_cmdline_end;
}
if (ccline.cmdbuff[ccline.cmdlen] != NUL) {
arg_allocated = true;
arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff,