diff options
author | luukvbaal <luukvbaal@gmail.com> | 2024-05-01 22:51:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 13:51:06 -0700 |
commit | e778e0116198470ba037b9426f4ff7fa5cb7f880 (patch) | |
tree | 17921986e3eed8347c60b821d287768ab437f401 /src/nvim/ex_getln.c | |
parent | 631d5189adaaf54eb48e0b136df3466880edb19c (diff) | |
download | rneovim-e778e0116198470ba037b9426f4ff7fa5cb7f880.tar.gz rneovim-e778e0116198470ba037b9426f4ff7fa5cb7f880.tar.bz2 rneovim-e778e0116198470ba037b9426f4ff7fa5cb7f880.zip |
fix(ui): avoid recursiveness and invalid memory access #28578
Problem: Calling :redraw from vim.ui_attach() callback results in
recursive cmdline/message events.
Solution: Avoid recursiveness where possible and replace global "call_buf"
with separate, temporary buffers for each event so that when a Lua
callback for one event fires another event, that does not result
in invalid memory access.
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a97c12568d..8c9e6e454a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3449,9 +3449,11 @@ void cmdline_screen_cleared(void) /// called by ui_flush, do what redraws necessary to keep cmdline updated. void cmdline_ui_flush(void) { - if (!ui_has(kUICmdline)) { + static bool flushing = false; + if (!ui_has(kUICmdline) || flushing) { return; } + flushing = true; int level = ccline.level; CmdlineInfo *line = &ccline; while (level > 0 && line) { @@ -3466,6 +3468,7 @@ void cmdline_ui_flush(void) } line = line->prev_ccline; } + flushing = false; } // Put a character on the command line. Shifts the following text to the |