diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-28 11:48:30 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-28 11:48:30 +0100 |
commit | ef976323e770315b5fca544efb6b2faa25674d15 (patch) | |
tree | bcbbeb67ecb9b2a445919e837089b682fd943d10 /src/buffer.c | |
parent | caa1d19da1cdfd07f93b578b4fd5214a53197cd6 (diff) |
patch 9.0.0614: SpellFileMissing autocmd may delete bufferv9.0.0614
Problem: SpellFileMissing autocmd may delete buffer.
Solution: Disallow deleting the current buffer to avoid using freed memory.
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index edf71b0513..be7f1fa8d4 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -468,7 +468,12 @@ can_unload_buffer(buf_T *buf) } } if (!can_unload) - semsg(_(e_attempt_to_delete_buffer_that_is_in_use_str), buf->b_fname); + { + char_u *fname = buf->b_fname != NULL ? buf->b_fname : buf->b_ffname; + + semsg(_(e_attempt_to_delete_buffer_that_is_in_use_str), + fname != NULL ? fname : (char_u *)"[No Name]"); + } return can_unload; } |