test: term_close use-after-free

References #4393
This commit is contained in:
Justin M. Keyes
2016-05-14 22:56:11 -04:00
parent df376d2e49
commit 8dd91ddb73
3 changed files with 15 additions and 8 deletions

View File

@@ -1,7 +1,5 @@
-- Test for text formatting.
local helpers = require('test.functional.helpers') local helpers = require('test.functional.helpers')
local feed, insert, source = helpers.feed, helpers.insert, helpers.source local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('text formatting', function() describe('text formatting', function()

View File

@@ -158,8 +158,7 @@ describe('terminal buffer', function()
end) end)
it('handles loss of focus gracefully', function() it('handles loss of focus gracefully', function()
-- Temporarily change the statusline to avoid printing the file name, which -- Change the statusline to avoid printing the file name, which varies.
-- varies be where the test is run.
nvim('set_option', 'statusline', '==========') nvim('set_option', 'statusline', '==========')
execute('set laststatus=0') execute('set laststatus=0')
@@ -195,5 +194,15 @@ describe('terminal buffer', function()
execute('set laststatus=1') -- Restore laststatus to the default. execute('set laststatus=1') -- Restore laststatus to the default.
end) end)
it('term_close() use-after-free #4393', function()
if eval("executable('yes')") == 0 then
pending('missing "yes" command')
return
end
execute('terminal yes')
feed([[<C-\><C-n>]])
execute('bdelete!')
end)
end) end)

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers') local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim
local nvim_dir, source, ok = helpers.nvim_dir, helpers.source, helpers.ok local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq
local execute, eval = helpers.execute, helpers.eval local execute, eval = helpers.execute, helpers.eval
describe(':terminal', function() describe(':terminal', function()
@@ -53,7 +53,7 @@ describe(':terminal', function()
source([[ source([[
autocmd BufNew * set shell=foo autocmd BufNew * set shell=foo
terminal]]) terminal]])
-- Verify that BufNew actually fired (else the test is useless). -- Verify that BufNew actually fired (else the test is invalid).
ok('foo' == eval('&shell')) eq('foo', eval('&shell'))
end) end)
end) end)