patch 9.1.2055: Division by zero in :file after failing to wipe buffer

Problem:  Division by zero in :file after failing to wipe buffer
          (after 8.2.4631).
Solution: Still call buf_clear_file() when failing to wipe buffer
          (zeertzjq).

closes: #19088

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2026-01-06 11:11:16 +00:00
committed by Christian Brabandt
parent 0ed8ba3079
commit 1aa5ca4ecb
3 changed files with 29 additions and 7 deletions
+3 -6
View File
@@ -707,7 +707,7 @@ aucmd_abort:
// If the buffer was in curwin and the window has changed, go back to that
// window, if it still exists. This avoids that ":edit x" triggering a
// "tabnext" BufUnload autocmd leaves a window behind without a buffer.
if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin))
if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin))
{
block_autocmds();
goto_tabpage_win(the_curtab, the_curwin);
@@ -782,16 +782,13 @@ aucmd_abort:
/*
* Remove the buffer from the list.
* Do not wipe out the buffer if it is used in a window.
*/
if (wipe_buf)
if (wipe_buf && buf->b_nwindows <= 0)
{
tabpage_T *tp;
win_T *wp;
// Do not wipe out the buffer if it is used in a window.
if (buf->b_nwindows > 0)
return FALSE;
FOR_ALL_TAB_WINDOWS(tp, wp)
mark_forget_file(wp, buf->b_fnum);