mirror of
https://github.com/neovim/neovim.git
synced 2026-08-30 19:11:52 +00:00
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
0db0c3c142
Co-authored-by: Sam Roeca <samuel.roeca@gmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user