neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 22d1fb8c014f3b457227d91dba62b86eec554459
parent bbc368dfce2547ff28698f4a2a7d629ee83ffba6
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Mon, 21 Jul 2025 07:15:56 +0800

vim-patch:9.1.1573: Memory leak when pressing Ctrl-D in cmdline mode

Problem:  Memory leak when pressing Ctrl-D in cmdline mode
          (after 9.1.1571).
Solution: Free prev_cmdbuff before assigning to it.
          (zeertzjq).

Existing tests already cover this. This change fixes the CI failure.

closes: vim/vim#17807

https://github.com/vim/vim/commit/c02bef26fdfbffd442cbc5acef375256fa7fd6ff

Diffstat:
Msrc/nvim/ex_getln.c | 5++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c @@ -1021,7 +1021,9 @@ theend: static int command_line_check(VimState *state) { CommandLineState *s = (CommandLineState *)state; + s->prev_cmdpos = ccline.cmdpos; + XFREE_CLEAR(s->prev_cmdbuff); redir_off = true; // Don't redirect the typed command. // Repeated, because a ":redir" inside @@ -2309,7 +2311,6 @@ static int command_line_not_changed(CommandLineState *s) // changed in the past. // Enter command_line_changed() when the command line did change. if (!s->is_state.incsearch_postponed) { - XFREE_CLEAR(s->prev_cmdbuff); return 1; } return command_line_changed(s); @@ -2787,8 +2788,6 @@ static int command_line_changed(CommandLineState *s) do_autocmd_cmdlinechanged(s->firstc > 0 ? s->firstc : '-'); } - XFREE_CLEAR(s->prev_cmdbuff); - may_trigger_cursormovedc(s); const bool prev_cmdpreview = cmdpreview;