2015-08-03 Benno Schulenberg <bensberg@justemail.net>
- * src/rcfile.c (parse_binding): Check value of shortcut->toggle
+ * src/rcfile.c (parse_binding): Check the value of shortcut->toggle
only if it actually is a toggle. Found with valgrind.
+ * src/files.c (write_lockfile): Plug a leak. Found with valgrind.
2015-08-02 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (initialize_buffer): Initialize also openfile->syntax.
myuid = geteuid();
if ((mypwuid = getpwuid(myuid)) == NULL) {
statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)"));
- return -1;
+ goto free_and_fail;
}
mypid = getpid();
if (gethostname(myhostname, 31) < 0) {
statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno));
- return -1;
+ goto free_and_fail;
}
/* Check if the lock exists before we try to delete it...*/
if (stat(lockfilename, &fileinfo) != -1)
if (delete_lockfile(lockfilename) < 0)
- return -1;
+ goto free_and_fail;
if (ISSET(INSECURE_BACKUP))
cflags = O_WRONLY | O_CREAT | O_APPEND;
if (fd < 0) {
statusbar(_("Error writing lock file %s: %s"), lockfilename,
strerror(errno));
+ free(lockdata);
return 0;
}
if (fd < 0 || filestream == NULL) {
statusbar(_("Error writing lock file %s: %s"), lockfilename,
strerror(errno));
- return -1;
+ goto free_and_fail;
}
/* Okay, so at the moment we're following this state for how to
if (wroteamt < lockdatalen) {
statusbar(_("Error writing lock file %s: %s"),
lockfilename, ferror(filestream));
- return -1;
+ goto free_and_fail;
}
#ifdef DEBUG
if (fclose(filestream) == EOF) {
statusbar(_("Error writing lock file %s: %s"),
lockfilename, strerror(errno));
- return -1;
+ goto free_and_fail;
}
openfile->lock_filename = (char *) lockfilename;
+ free(lockdata);
return 1;
+
+ free_and_fail:
+ free(lockdata);
+ return -1;
}
/* Less exciting, delete the lockfile. Return -1 if unsuccessful and