fix(window): avoid referencing cmdline_win after it is closed #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.
This commit is contained in:
luukvbaal
2025-09-04 01:28:23 +02:00
committed by GitHub
parent 17da1ad8f4
commit de950f8272
2 changed files with 11 additions and 0 deletions

View File

@@ -3138,6 +3138,10 @@ static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
if (win == win_tp->tp_curwin) { if (win == win_tp->tp_curwin) {
win_tp->tp_curwin = wp; win_tp->tp_curwin = wp;
} }
// Avoid executing cmdline_win logic after it is closed.
if (win == cmdline_win) {
cmdline_win = NULL;
}
return wp; return wp;
} }

View File

@@ -390,6 +390,13 @@ describe('vim.ui_attach', function()
9 bufname( {12: } | 9 bufname( {12: } |
Excommand:call bufadd^( | Excommand:call bufadd^( |
]]) ]])
-- No crash after _cmdline_offset window is closed #35584.
exec_lua(function()
vim.ui_detach(_G.ns)
vim.api.nvim_win_close(_G.win, true)
end)
feed('<Esc>:<Tab>')
n.assert_alive()
end) end)
end) end)