From 1f4335fe72717e3f4fe3e353fa70f26713f12312 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 3 Aug 2026 06:39:00 +0800 Subject: [PATCH] vim-patch:partial:9.2.0899: command output temporary files may collide (#41123) Problem: On MS-Windows, get_cmd_output() removes its reserved temporary file before the shell opens it, allowing another Vim process to reuse the same name. Solution: Keep the temporary file reserved until command output handling is complete (Sam Roeca). closes: vim/vim#20915 https://github.com/vim/vim/commit/0db0c3c142b9994b64c63162914ba4db528f88a2 Co-authored-by: Sam Roeca --- src/nvim/os/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index a1e0e64aa1..7683d6cbbc 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -813,7 +813,6 @@ char *get_cmd_output(char *cmd, char *infile, int flags, size_t *ret_len) buffer = xmalloc(len + 1); size_t i = fread(buffer, 1, len, fd); fclose(fd); - os_remove(tempname); if (i != len) { semsg(_(e_cant_read_file_str), tempname); XFREE_CLEAR(buffer); @@ -831,6 +830,7 @@ char *get_cmd_output(char *cmd, char *infile, int flags, size_t *ret_len) } done: + os_remove(tempname); xfree(tempname); return buffer; }