mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 19:48:32 +00:00
terminal: Fix use after free
Since close_cb may free the terminal structure, save the "wipe" flag before calling it.
This commit is contained in:
@@ -422,8 +422,9 @@ end:
|
||||
redraw(term->buf != curbuf);
|
||||
ui_busy_stop();
|
||||
if (close) {
|
||||
bool wipe = term->buf != NULL;
|
||||
term->opts.close_cb(term->opts.data);
|
||||
if (term->buf) {
|
||||
if (wipe) {
|
||||
do_cmdline_cmd("bwipeout!");
|
||||
}
|
||||
}
|
||||
|
@@ -343,6 +343,17 @@ describe('terminal prints more lines than the screen height and exits', function
|
||||
[Program exited, press any key to close] |
|
||||
-- TERMINAL -- |
|
||||
]])
|
||||
feed('<cr>')
|
||||
-- closes the buffer correctly after pressing a key
|
||||
screen:expect([[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user