aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/range.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-08-22 15:07:45 -0400
committerGitHub <noreply@github.com>2026-08-22 15:07:45 -0400
commit7037e1effe9e3c98d43b36a287dd39e87eaf1bb2 (patch)
treee850c95a08ffb7f2b550b806dde99b410d259d53 /runtime/lua/vim/range.lua
parentc149f4b93aa7f6b04a485b0fff7603cf014e7386 (diff)
downloadrneovim-7037e1effe9e3c98d43b36a287dd39e87eaf1bb2.tar.gz
rneovim-7037e1effe9e3c98d43b36a287dd39e87eaf1bb2.tar.bz2
rneovim-7037e1effe9e3c98d43b36a287dd39e87eaf1bb2.zip
fix(write): :write can target a garbage filename #41432
Problem: `buf_write()` captures the buffer's `fname`/`sfname`/`ffname`, then emits its progress-message before opening the file. This may run user code synchronously: the `Progress` autocmd, and the `msg_show` handler of an in-process UI (ui2). Either can change the CWD, and `shorten_fnames()` then frees/reallocs every buffer's short name. The rest of `buf_write()` reads the freed name... "foldtext()" [New] 41L, 997B written E212: Can't open file for writing: illegal byte sequence ASAN, with ui2 enabled and a `BufEnter` handler that runs `:lcd`: READ path_skip_sep <- path_tail <- match_file_list <- buf_write FREE shorten_buf_fname <- shorten_fnames <- update_cwd <- set_curbuf <- win_set_buf <- nvim_open_win <- ui2 msg_show handler <- ui_call_msg_show <- msg_ext_ui_flush <- buf_write Solution: Copy the names after the `*Pre` autocmds. Note: `readfile()` has the same shape, but its messages pass no progress-id, so they skip `msg_progress()`. Safe, for now...
Diffstat (limited to 'runtime/lua/vim/range.lua')
0 files changed, 0 insertions, 0 deletions