From 5cedb53c629869319e4adcd8bfba329fad955c3e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 12 Sep 2021 09:54:31 +0200 Subject: [PATCH] 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. --- src/files.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/files.c b/src/files.c index 3f8b5293..000c4b5b 100644 --- a/src/files.c +++ b/src/files.c @@ -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