Mercurial > vim
comparison src/window.c @ 23869:5a4f9c5c1b99 v8.2.2476
patch 8.2.2476: using freed memory when splitting window while closing buffer
Commit: https://github.com/vim/vim/commit/983d83ff1cd796ff321074335fa53fbe7ac45a46
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 7 12:12:43 2021 +0100
patch 8.2.2476: using freed memory when splitting window while closing buffer
Problem: Using freed memory when using an autocommand to split a window
while a buffer is being closed.
Solution: Disallow splitting when the buffer has b_locked_split set.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 07 Feb 2021 12:15:03 +0100 |
parents | 65718283239b |
children | b5a6de6a8915 |
comparison
equal
deleted
inserted
replaced
23868:1a97398d5e5a | 23869:5a4f9c5c1b99 |
---|---|
767 if (split_disallowed > 0) | 767 if (split_disallowed > 0) |
768 { | 768 { |
769 emsg(_("E242: Can't split a window while closing another")); | 769 emsg(_("E242: Can't split a window while closing another")); |
770 return FAIL; | 770 return FAIL; |
771 } | 771 } |
772 if (curwin->w_buffer->b_locked_split) | |
773 { | |
774 emsg(_(e_cannot_split_window_when_closing_buffer)); | |
775 return FAIL; | |
776 } | |
772 return OK; | 777 return OK; |
773 } | 778 } |
774 | 779 |
775 /* | 780 /* |
776 * split the current window, implements CTRL-W s and :split | 781 * split the current window, implements CTRL-W s and :split |
791 win_split(int size, int flags) | 796 win_split(int size, int flags) |
792 { | 797 { |
793 if (ERROR_IF_ANY_POPUP_WINDOW) | 798 if (ERROR_IF_ANY_POPUP_WINDOW) |
794 return FAIL; | 799 return FAIL; |
795 | 800 |
801 if (check_split_disallowed() == FAIL) | |
802 return FAIL; | |
803 | |
796 // When the ":tab" modifier was used open a new tab page instead. | 804 // When the ":tab" modifier was used open a new tab page instead. |
797 if (may_open_tabpage() == OK) | 805 if (may_open_tabpage() == OK) |
798 return OK; | 806 return OK; |
799 | 807 |
800 // Add flags from ":vertical", ":topleft" and ":botright". | 808 // Add flags from ":vertical", ":topleft" and ":botright". |
802 if ((flags & WSP_TOP) && (flags & WSP_BOT)) | 810 if ((flags & WSP_TOP) && (flags & WSP_BOT)) |
803 { | 811 { |
804 emsg(_("E442: Can't split topleft and botright at the same time")); | 812 emsg(_("E442: Can't split topleft and botright at the same time")); |
805 return FAIL; | 813 return FAIL; |
806 } | 814 } |
807 if (check_split_disallowed() == FAIL) | |
808 return FAIL; | |
809 | 815 |
810 // When creating the help window make a snapshot of the window layout. | 816 // When creating the help window make a snapshot of the window layout. |
811 // Otherwise clear the snapshot, it's now invalid. | 817 // Otherwise clear the snapshot, it's now invalid. |
812 if (flags & WSP_HELP) | 818 if (flags & WSP_HELP) |
813 make_snapshot(SNAP_HELP_IDX); | 819 make_snapshot(SNAP_HELP_IDX); |