Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_exit.vim +++ b/src/testdir/test_exit.vim @@ -40,6 +40,7 @@ func Test_exiting() endif call delete('Xtestout') + " ExitPre autocommand splits the window, so that it's no longer the last one. let after =<< trim [CODE] au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") @@ -58,4 +59,25 @@ func Test_exiting() \ readfile('Xtestout')) endif call delete('Xtestout') + + " ExitPre autocommand splits and closes the window, so that there is still + " one window but it's a different one. + let after =<< trim [CODE] + au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") + au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") + augroup nasty + au ExitPre * split | only + augroup END + quit + augroup nasty + au! ExitPre + augroup END + quit + [CODE] + + if RunVim([], after, '') + call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], + \ readfile('Xtestout')) + endif + call delete('Xtestout') endfunc