diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-04-17 23:24:06 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-04-17 23:24:06 +0200 |
commit | a997b45c7e350ea5b378ca0c52ed3d4cc610975c (patch) | |
tree | 4ce7c2e8741723990ad32cea475b013215a250e8 /src/buffer.c | |
parent | e87edf3b85f607632e5431640071fdbc36b685b2 (diff) |
patch 8.0.1732: crash when terminal API call deletes the bufferv8.0.1732
Problem: Crash when terminal API call deletes the buffer.
Solution: Lock the buffer while calling a function. (closes #2813)
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index 4563736b4d..c3d3d77b0f 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -417,6 +417,8 @@ buf_hashtab_remove(buf_T *buf) hash_remove(&buf_hashtab, hi); } +static char *e_buflocked = N_("E937: Attempt to delete a buffer that is in use"); + /* * Close the link to a buffer. * "action" is used when there is no longer a window for the buffer. @@ -476,8 +478,15 @@ close_buffer( if (term_job_running(buf->b_term)) { if (wipe_buf || unload_buf) + { + if (buf->b_locked) + { + EMSG(_(e_buflocked)); + return; + } /* Wiping out or unloading a terminal buffer kills the job. */ free_terminal(buf); + } else { /* The job keeps running, hide the buffer. */ @@ -499,7 +508,7 @@ close_buffer( * halfway a command that relies on it). Unloading is allowed. */ if (buf->b_locked > 0 && (del_buf || wipe_buf)) { - EMSG(_("E937: Attempt to delete a buffer that is in use")); + EMSG(_(e_buflocked)); return; } @@ -1356,6 +1365,12 @@ do_buffer( int forward; bufref_T bufref; + if (buf->b_locked) + { + EMSG(_(e_buflocked)); + return FAIL; + } + set_bufref(&bufref, buf); /* When unloading or deleting a buffer that's already unloaded and |