Mercurial > vim
comparison src/ex_cmds.c @ 23624:f9d02c83f306 v8.2.2354
patch 8.2.2354: crash with a weird combination of autocommands
Commit: https://github.com/vim/vim/commit/797e63b9f2baa1853e7063aac478d663cd02f207
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 15 16:22:52 2021 +0100
patch 8.2.2354: crash with a weird combination of autocommands
Problem: Crash with a weird combination of autocommands.
Solution: Increment b_nwindows when needed. (closes https://github.com/vim/vim/issues/7674)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 15 Jan 2021 16:30:04 +0100 |
parents | 049b1e867137 |
children | 062caef90f7f |
comparison
equal
deleted
inserted
replaced
23623:905ba483e284 | 23624:f9d02c83f306 |
---|---|
2740 if (buf == curbuf) // already in new buffer | 2740 if (buf == curbuf) // already in new buffer |
2741 auto_buf = TRUE; | 2741 auto_buf = TRUE; |
2742 else | 2742 else |
2743 { | 2743 { |
2744 win_T *the_curwin = curwin; | 2744 win_T *the_curwin = curwin; |
2745 int did_decrement; | |
2746 buf_T *was_curbuf = curbuf; | |
2745 | 2747 |
2746 // Set the w_closing flag to avoid that autocommands close the | 2748 // Set the w_closing flag to avoid that autocommands close the |
2747 // window. And set b_locked for the same reason. | 2749 // window. And set b_locked for the same reason. |
2748 the_curwin->w_closing = TRUE; | 2750 the_curwin->w_closing = TRUE; |
2749 ++buf->b_locked; | 2751 ++buf->b_locked; |
2752 buf_copy_options(buf, BCO_ENTER); | 2754 buf_copy_options(buf, BCO_ENTER); |
2753 | 2755 |
2754 // Close the link to the current buffer. This will set | 2756 // Close the link to the current buffer. This will set |
2755 // oldwin->w_buffer to NULL. | 2757 // oldwin->w_buffer to NULL. |
2756 u_sync(FALSE); | 2758 u_sync(FALSE); |
2757 close_buffer(oldwin, curbuf, | 2759 did_decrement = close_buffer(oldwin, curbuf, |
2758 (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE); | 2760 (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE); |
2759 | 2761 |
2760 the_curwin->w_closing = FALSE; | 2762 the_curwin->w_closing = FALSE; |
2761 --buf->b_locked; | 2763 --buf->b_locked; |
2762 | 2764 |
2774 // new buffer has been deleted | 2776 // new buffer has been deleted |
2775 delbuf_msg(new_name); // frees new_name | 2777 delbuf_msg(new_name); // frees new_name |
2776 goto theend; | 2778 goto theend; |
2777 } | 2779 } |
2778 if (buf == curbuf) // already in new buffer | 2780 if (buf == curbuf) // already in new buffer |
2781 { | |
2782 // close_buffer() has decremented the window count, | |
2783 // increment it again here and restore w_buffer. | |
2784 if (did_decrement && buf_valid(was_curbuf)) | |
2785 ++was_curbuf->b_nwindows; | |
2786 if (win_valid_any_tab(oldwin) && oldwin->w_buffer == NULL) | |
2787 oldwin->w_buffer = was_curbuf; | |
2779 auto_buf = TRUE; | 2788 auto_buf = TRUE; |
2789 } | |
2780 else | 2790 else |
2781 { | 2791 { |
2782 #ifdef FEAT_SYN_HL | 2792 #ifdef FEAT_SYN_HL |
2783 /* | 2793 /* |
2784 * <VN> We could instead free the synblock | 2794 * <VN> We could instead free the synblock |