Mercurial > vim
comparison src/arglist.c @ 26711:5860bd619d30 v8.2.3884
patch 8.2.3884: crash when clearing the argument list while using it
Commit: https://github.com/vim/vim/commit/6f98371532fcff911b462d51bc64f2ce8a6ae682
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Dec 24 18:11:27 2021 +0000
patch 8.2.3884: crash when clearing the argument list while using it
Problem: Crash when clearing the argument list while using it.
Solution: Lock the argument list for ":all".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 Dec 2021 19:15:03 +0100 |
parents | a2e6da79274d |
children | 2bdcce61a4e4 |
comparison
equal
deleted
inserted
replaced
26710:8fd8af3764e2 | 26711:5860bd619d30 |
---|---|
908 int had_tab = cmdmod.cmod_tab; | 908 int had_tab = cmdmod.cmod_tab; |
909 win_T *old_curwin, *last_curwin; | 909 win_T *old_curwin, *last_curwin; |
910 tabpage_T *old_curtab, *last_curtab; | 910 tabpage_T *old_curtab, *last_curtab; |
911 win_T *new_curwin = NULL; | 911 win_T *new_curwin = NULL; |
912 tabpage_T *new_curtab = NULL; | 912 tabpage_T *new_curtab = NULL; |
913 int prev_arglist_locked = arglist_locked; | |
913 | 914 |
914 #ifdef FEAT_CMDWIN | 915 #ifdef FEAT_CMDWIN |
915 if (cmdwin_type != 0) | 916 if (cmdwin_type != 0) |
916 { | 917 { |
917 emsg(_(e_invalid_in_cmdline_window)); | 918 emsg(_(e_invalid_in_cmdline_window)); |
934 // Autocommands may do anything to the argument list. Make sure it's not | 935 // Autocommands may do anything to the argument list. Make sure it's not |
935 // freed while we are working here by "locking" it. We still have to | 936 // freed while we are working here by "locking" it. We still have to |
936 // watch out for its size to be changed. | 937 // watch out for its size to be changed. |
937 alist = curwin->w_alist; | 938 alist = curwin->w_alist; |
938 ++alist->al_refcount; | 939 ++alist->al_refcount; |
940 arglist_locked = TRUE; | |
939 | 941 |
940 old_curwin = curwin; | 942 old_curwin = curwin; |
941 old_curtab = curtab; | 943 old_curtab = curtab; |
942 | 944 |
943 # ifdef FEAT_GUI | 945 # ifdef FEAT_GUI |
1153 cmdmod.cmod_tab = 9999; | 1155 cmdmod.cmod_tab = 9999; |
1154 } | 1156 } |
1155 | 1157 |
1156 // Remove the "lock" on the argument list. | 1158 // Remove the "lock" on the argument list. |
1157 alist_unlink(alist); | 1159 alist_unlink(alist); |
1160 arglist_locked = prev_arglist_locked; | |
1158 | 1161 |
1159 --autocmd_no_enter; | 1162 --autocmd_no_enter; |
1160 | 1163 |
1161 // restore last referenced tabpage's curwin | 1164 // restore last referenced tabpage's curwin |
1162 if (last_curtab != new_curtab) | 1165 if (last_curtab != new_curtab) |