aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2016-05-15 15:39:15 -0400
committerJustin M. Keyes <justinkz@gmail.com>2016-05-15 19:47:24 -0400
commitf583bc94fc7e08cca6ca85ea5a3cd38368e54df7 (patch)
tree6e6241d851e4ba4518e12b7e8d5cdea65c34f77b /src
parent8dd91ddb73ba31e451e76b72861fea90fede1de3 (diff)
downloadrneovim-f583bc94fc7e08cca6ca85ea5a3cd38368e54df7.tar.gz
rneovim-f583bc94fc7e08cca6ca85ea5a3cd38368e54df7.tar.bz2
rneovim-f583bc94fc7e08cca6ca85ea5a3cd38368e54df7.zip
term_close: fix use-after-free
Closes #4393
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 8c8881b398..712ee06b85 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -21701,6 +21701,18 @@ static void term_resize(uint16_t width, uint16_t height, void *d)
pty_process_resize(&data->proc.pty, width, height);
}
+static inline void term_delayed_free(void **argv)
+{
+ TerminalJobData *j = argv[0];
+ if (j->in.pending_reqs || j->out.pending_reqs || j->err.pending_reqs) {
+ queue_put(j->events, term_delayed_free, 1, j);
+ return;
+ }
+
+ terminal_destroy(j->term);
+ term_job_data_decref(j);
+}
+
static void term_close(void *d)
{
TerminalJobData *data = d;
@@ -21708,8 +21720,7 @@ static void term_close(void *d)
data->exited = true;
process_stop((Process *)&data->proc);
}
- terminal_destroy(data->term);
- term_job_data_decref(d);
+ queue_put(data->events, term_delayed_free, 1, data);
}
static void term_job_data_decref(TerminalJobData *data)