comparison src/testdir/test_exit.vim @ 18406:fa6efc49d71f v8.1.2197

patch 8.1.2197: ExitPre autocommand may cause accessing freed memory Commit: https://github.com/vim/vim/commit/34ba06b6e6f94bb46062e6c85dbfdcbb0d255ada Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 20 22:27:10 2019 +0200 patch 8.1.2197: ExitPre autocommand may cause accessing freed memory Problem: ExitPre autocommand may cause accessing freed memory. Solution: Check the window pointer is still valid. (closes https://github.com/vim/vim/issues/5093)
author Bram Moolenaar <Bram@vim.org>
date Sun, 20 Oct 2019 22:30:03 +0200
parents 9c90cf08cfa8
children 08940efa6b4e
comparison
equal deleted inserted replaced
18405:ef35dddb7189 18406:fa6efc49d71f
38 if RunVim([], after, '') 38 if RunVim([], after, '')
39 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) 39 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
40 endif 40 endif
41 call delete('Xtestout') 41 call delete('Xtestout')
42 42
43 " ExitPre autocommand splits the window, so that it's no longer the last one.
43 let after =<< trim [CODE] 44 let after =<< trim [CODE]
44 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") 45 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
45 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") 46 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
46 augroup nasty 47 augroup nasty
47 au ExitPre * split 48 au ExitPre * split
56 if RunVim([], after, '') 57 if RunVim([], after, '')
57 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], 58 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
58 \ readfile('Xtestout')) 59 \ readfile('Xtestout'))
59 endif 60 endif
60 call delete('Xtestout') 61 call delete('Xtestout')
62
63 " ExitPre autocommand splits and closes the window, so that there is still
64 " one window but it's a different one.
65 let after =<< trim [CODE]
66 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
67 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
68 augroup nasty
69 au ExitPre * split | only
70 augroup END
71 quit
72 augroup nasty
73 au! ExitPre
74 augroup END
75 quit
76 [CODE]
77
78 if RunVim([], after, '')
79 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
80 \ readfile('Xtestout'))
81 endif
82 call delete('Xtestout')
61 endfunc 83 endfunc