diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-18 08:21:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-18 08:21:24 +0800 |
commit | 7ded303d684605ea44846c5f8a4031326529fb6d (patch) | |
tree | 0db0e34b5f4a55aa68a43e273e0674489566932d /src/nvim/ex_getln.c | |
parent | 38cbca3eeadca86f1431ea7a97f498f6a9cd33c8 (diff) | |
download | rneovim-7ded303d684605ea44846c5f8a4031326529fb6d.tar.gz rneovim-7ded303d684605ea44846c5f8a4031326529fb6d.tar.bz2 rneovim-7ded303d684605ea44846c5f8a4031326529fb6d.zip |
vim-patch:8.2.4975: recursive command line loop may cause a crash (#18614)
Problem: Recursive command line loop may cause a crash.
Solution: Limit recursion of getcmdline().
https://github.com/vim/vim/commit/51f0bfb88a3554ca2dde777d78a59880d1ee37a8
Cherry-pick e_command_too_recursive from patch 8.2.3957.
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 114f1e2ae5..1d496cbf25 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -804,6 +804,12 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init ccline.cmdlen = s->indent; } + if (cmdline_level == 50) { + // Somehow got into a loop recursively calling getcmdline(), bail out. + emsg(_(e_command_too_recursive)); + goto theend; + } + ExpandInit(&s->xpc); ccline.xpc = &s->xpc; @@ -995,12 +1001,13 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init State = s->save_State; setmouse(); ui_cursor_shape(); // may show different cursor shape + sb_text_end_cmdline(); + +theend: xfree(s->save_p_icm); xfree(ccline.last_colors.cmdbuff); kv_destroy(ccline.last_colors.colors); - sb_text_end_cmdline(); - char_u *p = ccline.cmdbuff; if (ui_has(kUICmdline)) { |