annotate runtime/ftplugin.vim @ 33862:242b964d6269 v9.0.2140

patch 9.0.2140: [security]: use-after-free in win-enter Commit: https://github.com/vim/vim/commit/eec0c2b3a4cfab93dd8d4adaa60638d47a2bbc8a Author: Christian Brabandt <cb@256bit.org> Date: Tue Nov 28 22:03:48 2023 +0100 patch 9.0.2140: [security]: use-after-free in win-enter Problem: [security]: use-after-free in win-enter Solution: validate window pointer before calling win_enter() win_goto() may stop visual mode, if it is active. However, this may in turn trigger the ModeChanged autocommand, which could potentially free the wp pointer which was valid before now became stale and points to now freed memory. So before calling win_enter(), let's verify one more time, that the wp pointer still points to a valid window structure. Reported by @henices, thanks! Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Dec 2023 15:16:01 +0100
parents 4027cefc2aab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
1 vim9script noclear
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
3 # Vim support file to switch on loading plugins for file types
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
4 #
32770
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 27634
diff changeset
5 # Maintainer: The Vim Project <https://github.com/vim/vim>
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 27634
diff changeset
6 # Last change: 2023 Aug 10
4027cefc2aab Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents: 27634
diff changeset
7 # Former Maintainer: Bram Moolenaar <Bram@vim.org>
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
8
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
9 if exists("g:did_load_ftplugin")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
12 g:did_load_ftplugin = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 augroup filetypeplugin
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
15 au FileType * call LoadFTPlugin()
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
16 augroup END
856
8cd729851562 updated for version 7.0g
vimboss
parents: 782
diff changeset
17
27623
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
18 if exists('*LoadFTPlugin')
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
19 # No need to define the function again.
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
20 finish
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
21 endif
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
22
179c118424a6 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
23 def LoadFTPlugin()
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
24 if exists("b:undo_ftplugin")
27634
9fe2fed9bb4b Update runtime files. (closes #9741)
Bram Moolenaar <Bram@vim.org>
parents: 27623
diff changeset
25 # We assume b:undo_ftplugin is using legacy script syntax
9fe2fed9bb4b Update runtime files. (closes #9741)
Bram Moolenaar <Bram@vim.org>
parents: 27623
diff changeset
26 legacy exe b:undo_ftplugin
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
27 unlet! b:undo_ftplugin b:did_ftplugin
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
28 endif
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
29
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
30 var s = expand("<amatch>")
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
31 if s != ""
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
32 if &cpo =~# "S" && exists("b:did_ftplugin")
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
33 # In compatible mode options are reset to the global values, need to
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
34 # set the local values also when a plugin was already used.
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
35 unlet b:did_ftplugin
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 36
diff changeset
36 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 782
diff changeset
37
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
38 # When there is a dot it is used to separate filetype names. Thus for
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
39 # "aaa.bbb" load "aaa" and then "bbb".
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
40 for name in split(s, '\.')
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
41 exe 'runtime! ftplugin/' .. name .. '.vim ftplugin/' .. name .. '_*.vim ftplugin/' .. name .. '/*.vim'
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
42 endfor
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
43 endif
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 856
diff changeset
44 enddef