diff options
-rw-r--r-- | src/bufwrite.c | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/bufwrite.c b/src/bufwrite.c index 8db4266265..d7c3034766 100644 --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -1208,14 +1208,22 @@ buf_write( // First find a file name that doesn't exist yet (use some // arbitrary numbers). STRCPY(IObuff, fname); + fd = -1; for (i = 4913; ; i += 123) { sprintf((char *)gettail(IObuff), "%d", i); if (mch_lstat((char *)IObuff, &st) < 0) + { + fd = mch_open((char *)IObuff, + O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm); + if (fd < 0 && errno == EEXIST) + // If the same file name is created by another + // process between lstat() and open(), find another + // name. + continue; break; + } } - fd = mch_open((char *)IObuff, - O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm); if (fd < 0) // can't write in directory backup_copy = TRUE; else diff --git a/src/version.c b/src/version.c index 5f276d4b79..0a38f39677 100644 --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 119, +/**/ 118, /**/ 117, |