Patch 8.2.2055
Problem:    MS-Windows: two Vim instances may use the same temp file.
Solution:   Use the process ID for the temp name. (Ken Takata, closes #7378)
Files:      src/fileio.c


*** ../vim-8.2.2054/src/fileio.c        2020-10-28 20:19:56.372057081 +0100
--- src/fileio.c        2020-11-26 19:46:10.404168320 +0100
***************
*** 5167,5183 ****
  # ifdef MSWIN
      WCHAR     wszTempFile[_MAX_PATH + 1];
      WCHAR     buf4[4];
      char_u    *retval;
      char_u    *p;
  
      wcscpy(itmp, L"");
      if (GetTempPathW(_MAX_PATH, wszTempFile) == 0)
      {
        wszTempFile[0] = L'.';  // GetTempPathW() failed, use current dir
!       wszTempFile[1] = NUL;
      }
      wcscpy(buf4, L"VIM");
!     buf4[2] = extra_char;   // make it "VIa", "VIb", etc.
      if (GetTempFileNameW(wszTempFile, buf4, 0, itmp) == 0)
        return NULL;
      if (!keep)
--- 5167,5190 ----
  # ifdef MSWIN
      WCHAR     wszTempFile[_MAX_PATH + 1];
      WCHAR     buf4[4];
+     WCHAR     *chartab = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      char_u    *retval;
      char_u    *p;
+     long      i;
  
      wcscpy(itmp, L"");
      if (GetTempPathW(_MAX_PATH, wszTempFile) == 0)
      {
        wszTempFile[0] = L'.';  // GetTempPathW() failed, use current dir
!       wszTempFile[1] = L'\\';
!       wszTempFile[2] = NUL;
      }
      wcscpy(buf4, L"VIM");
! 
!     // randomize the name to avoid collisions
!     i = mch_get_pid() + extra_char;
!     buf4[1] = chartab[i % 36];
!     buf4[2] = chartab[101 * i % 36];
      if (GetTempFileNameW(wszTempFile, buf4, 0, itmp) == 0)
        return NULL;
      if (!keep)
*** ../vim-8.2.2054/src/version.c       2020-11-25 21:55:41.011368741 +0100
--- src/version.c       2020-11-26 19:47:16.727887178 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2055,
  /**/

-- 
DEAD PERSON:  I don't want to go in the cart!
CUSTOMER:     Oh, don't be such a baby.
MORTICIAN:    I can't take him...
DEAD PERSON:  I feel fine!
CUSTOMER:     Oh, do us a favor...
MORTICIAN:    I can't.
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202011261848.0AQIm7dg2420020%40masaka.moolenaar.net.

Raspunde prin e-mail lui