files: write a lock file also for a freshly saved buffer

This fixes https://savannah.gnu.org/bugs/?61146

Bug existed since version 2.3.2, since --locking was introduced,
and continued to exist since version 4.8 despite commit 497f126b
claiming to have fixed it.
master
Benno Schulenberg 2021-09-12 09:54:31 +02:00
parent 650dc14e0f
commit 5cedb53c62
1 changed files with 3 additions and 1 deletions

View File

@ -1978,8 +1978,10 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
if (openfile->lock_filename != NULL) {
delete_lockfile(openfile->lock_filename);
free(openfile->lock_filename);
openfile->lock_filename = do_lockfile(realname, FALSE);
}
if (ISSET(LOCKING))
openfile->lock_filename = do_lockfile(realname, FALSE);
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
#ifdef ENABLE_COLOR