From 0bdf849520e8324fb9c6da2a8baeea6670e80f77 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 9 Nov 2021 10:17:32 +0800 Subject: [PATCH] fix(terminal): free terminal if close_buffer() closes a closed terminal --- src/nvim/terminal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 13005b263e51eb..016e1a5a97b7d4 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -262,6 +262,9 @@ Terminal *terminal_open(buf_T *buf, TerminalOptions opts) void terminal_close(Terminal *term, int status) { if (term->closed) { + if (status == -1 && !term->refcount) { + terminal_destroy(term); + } return; }