Skip to content

Commit de950f8

Browse files
authored
fix(window): avoid referencing cmdline_win after it is closed neovim#35617
Solution: A window marked for ext_cmdline usage is still referenced after it is already closed and freed. Solution: Unset cmdline_win when the window is closed.
1 parent 17da1ad commit de950f8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/nvim/window.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,6 +3138,10 @@ static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
31383138
if (win == win_tp->tp_curwin) {
31393139
win_tp->tp_curwin = wp;
31403140
}
3141+
// Avoid executing cmdline_win logic after it is closed.
3142+
if (win == cmdline_win) {
3143+
cmdline_win = NULL;
3144+
}
31413145

31423146
return wp;
31433147
}

test/functional/lua/ui_event_spec.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ describe('vim.ui_attach', function()
390390
9 bufname( {12: } |
391391
Excommand:call bufadd^( |
392392
]])
393+
-- No crash after _cmdline_offset window is closed #35584.
394+
exec_lua(function()
395+
vim.ui_detach(_G.ns)
396+
vim.api.nvim_win_close(_G.win, true)
397+
end)
398+
feed('<Esc>:<Tab>')
399+
n.assert_alive()
393400
end)
394401
end)
395402

0 commit comments

Comments
 (0)