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: #20915
Signed-off-by: Sam Roeca <samuel.roeca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
if (check_restricted() || check_secure())
return NULL;
- // get a name for the temp file
- if ((tempname = vim_tempname('o', FALSE)) == NULL)
+ // Keep the file reserved until the shell opens it. On MS-Windows,
+ // deleting it here would let another Vim process reuse the same name.
+ if ((tempname = vim_tempname('o', TRUE)) == NULL)
{
emsg(_(e_cant_get_temp_file_name));
return NULL;
if (buffer != NULL)
i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd);
fclose(fd);
- mch_remove(tempname);
if (buffer == NULL)
goto done;
# ifdef VMS
*ret_len = len;
done:
+ mch_remove(tempname);
vim_free(tempname);
return buffer;
}
{
return x > INT_MAX ? INT_MAX : x < INT_MIN ? INT_MIN : x;
}
-
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 899,
/**/
898,
/**/