2015-11-10 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Skip a zero-length match only when there
/is/ a match. Found with valgrind. This fixes Savannah bug #41908.
+ * src/files.c (do_lockfile, update_poshistory): Plug memory leaks.
2015-11-08 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init): Allow exiting from the file browser
* complain to the user. */
int do_lockfile(const char *filename)
{
- char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
- char *lockbase = basename((char *) mallocstrcpy(NULL, filename));
+ char *namecopy1 = (char *) mallocstrcpy(NULL, filename);
+ char *namecopy2 = (char *) mallocstrcpy(NULL, filename);
size_t locknamesize = strlen(filename) + strlen(locking_prefix)
+ strlen(locking_suffix) + 3;
char *lockfilename = charalloc(locknamesize);
struct stat fileinfo;
int lockfd, lockpid;
- snprintf(lockfilename, locknamesize, "%s/%s%s%s", lockdir,
- locking_prefix, lockbase, locking_suffix);
+ snprintf(lockfilename, locknamesize, "%s/%s%s%s", dirname(namecopy1),
+ locking_prefix, basename(namecopy2), locking_suffix);
+ free(namecopy1);
+ free(namecopy2);
#ifdef DEBUG
fprintf(stderr, "lock file name is %s\n", lockfilename);
#endif
if (stat(lockfiledir, &fileinfo) == -1) {
statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"),
lockfiledir);
+ free(lockfiledir);
return 0;
}
+ free(lockfiledir);
}
return write_lockfile(lockfilename, filename, FALSE);
if (!strcmp(posptr->filename, fullpath)) {
posptr->lineno = lineno;
posptr->xno = xpos;
+ free(fullpath);
return;
}
posprev = posptr;