mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06: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:
parent
f9778052af
commit
105a72eabc
@ -422,8 +422,9 @@ end:
|
|||||||
redraw(term->buf != curbuf);
|
redraw(term->buf != curbuf);
|
||||||
ui_busy_stop();
|
ui_busy_stop();
|
||||||
if (close) {
|
if (close) {
|
||||||
|
bool wipe = term->buf != NULL;
|
||||||
term->opts.close_cb(term->opts.data);
|
term->opts.close_cb(term->opts.data);
|
||||||
if (term->buf) {
|
if (wipe) {
|
||||||
do_cmdline_cmd("bwipeout!");
|
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] |
|
[Program exited, press any key to close] |
|
||||||
-- TERMINAL -- |
|
-- TERMINAL -- |
|
||||||
]])
|
]])
|
||||||
|
feed('<cr>')
|
||||||
|
-- closes the buffer correctly after pressing a key
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
|
|
||||||
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user