Mercurial > vim
diff src/buffer.c @ 30558:8e73ecbee60d v9.0.0614
patch 9.0.0614: SpellFileMissing autocmd may delete buffer
Commit: https://github.com/vim/vim/commit/ef976323e770315b5fca544efb6b2faa25674d15
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 28 11:48:30 2022 +0100
patch 9.0.0614: SpellFileMissing autocmd may delete buffer
Problem: SpellFileMissing autocmd may delete buffer.
Solution: Disallow deleting the current buffer to avoid using freed memory.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 28 Sep 2022 13:00:04 +0200 |
parents | a4eab0d846dc |
children | 37aa9fd2ed72 |
line wrap: on
line diff
--- 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; }