diff --git a/ChangeLog b/ChangeLog
index faa7481e2df0ffc8cf6d8332a2e86a01902180f9..e6da1effd0af423df63983bc6c7a6a1be7b75684 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2015-07-10  Benno Schulenberg  <bensberg@justemail.net>
 	* src/nano.c (delete_opennode): Plug a small memory leak.
+	* src/files.c (do_lockfile): Rename a variable; it does not contain
+	the size of the file but the size of the name.
 
 2015-07-06  Benno Schulenberg  <bensberg@justemail.net>
 	* src/global.c (add_to_sclist), src/help.c (help_init), src/nano.h,
diff --git a/src/files.c b/src/files.c
index ca8848ff762a88f58a309186fe3b8c3d7a398d56..9aa7a79abc63e785d1af45fc9a485e981c657d55 100644
--- a/src/files.c
+++ b/src/files.c
@@ -249,15 +249,15 @@ int do_lockfile(const char *filename)
 {
     char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
     char *lockbase = basename((char *) mallocstrcpy(NULL, filename));
-    size_t lockfilesize = strlen(filename) + strlen(locking_prefix)
+    size_t locknamesize = strlen(filename) + strlen(locking_prefix)
 		+ strlen(locking_suffix) + 3;
-    char *lockfilename = charalloc(lockfilesize);
+    char *lockfilename = charalloc(locknamesize);
     char *lockfiledir = NULL;
     static char lockprog[11], lockuser[17];
     struct stat fileinfo;
     int lockfd, lockpid;
 
-    snprintf(lockfilename, lockfilesize, "%s/%s%s%s", lockdir,
+    snprintf(lockfilename, locknamesize, "%s/%s%s%s", lockdir,
 		locking_prefix, lockbase, locking_suffix);
 #ifdef DEBUG
     fprintf(stderr, "lock file name is %s\n", lockfilename);