Plugging four memory leaks.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5399 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
02a3a25aa0
commit
619f28077c
|
@ -1,6 +1,7 @@
|
||||||
2015-11-10 Benno Schulenberg <bensberg@justemail.net>
|
2015-11-10 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/winio.c (edit_draw): Skip a zero-length match only when there
|
* src/winio.c (edit_draw): Skip a zero-length match only when there
|
||||||
/is/ a match. Found with valgrind. This fixes Savannah bug #41908.
|
/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>
|
2015-11-08 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/global.c (shortcut_init): Allow exiting from the file browser
|
* src/global.c (shortcut_init): Allow exiting from the file browser
|
||||||
|
|
13
src/files.c
13
src/files.c
|
@ -251,8 +251,8 @@ int delete_lockfile(const char *lockfilename)
|
||||||
* complain to the user. */
|
* complain to the user. */
|
||||||
int do_lockfile(const char *filename)
|
int do_lockfile(const char *filename)
|
||||||
{
|
{
|
||||||
char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
|
char *namecopy1 = (char *) mallocstrcpy(NULL, filename);
|
||||||
char *lockbase = basename((char *) mallocstrcpy(NULL, filename));
|
char *namecopy2 = (char *) mallocstrcpy(NULL, filename);
|
||||||
size_t locknamesize = strlen(filename) + strlen(locking_prefix)
|
size_t locknamesize = strlen(filename) + strlen(locking_prefix)
|
||||||
+ strlen(locking_suffix) + 3;
|
+ strlen(locking_suffix) + 3;
|
||||||
char *lockfilename = charalloc(locknamesize);
|
char *lockfilename = charalloc(locknamesize);
|
||||||
|
@ -261,8 +261,10 @@ int do_lockfile(const char *filename)
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
int lockfd, lockpid;
|
int lockfd, lockpid;
|
||||||
|
|
||||||
snprintf(lockfilename, locknamesize, "%s/%s%s%s", lockdir,
|
snprintf(lockfilename, locknamesize, "%s/%s%s%s", dirname(namecopy1),
|
||||||
locking_prefix, lockbase, locking_suffix);
|
locking_prefix, basename(namecopy2), locking_suffix);
|
||||||
|
free(namecopy1);
|
||||||
|
free(namecopy2);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "lock file name is %s\n", lockfilename);
|
fprintf(stderr, "lock file name is %s\n", lockfilename);
|
||||||
#endif
|
#endif
|
||||||
|
@ -309,8 +311,10 @@ int do_lockfile(const char *filename)
|
||||||
if (stat(lockfiledir, &fileinfo) == -1) {
|
if (stat(lockfiledir, &fileinfo) == -1) {
|
||||||
statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"),
|
statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"),
|
||||||
lockfiledir);
|
lockfiledir);
|
||||||
|
free(lockfiledir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
free(lockfiledir);
|
||||||
}
|
}
|
||||||
|
|
||||||
return write_lockfile(lockfilename, filename, FALSE);
|
return write_lockfile(lockfilename, filename, FALSE);
|
||||||
|
@ -3155,6 +3159,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||||
if (!strcmp(posptr->filename, fullpath)) {
|
if (!strcmp(posptr->filename, fullpath)) {
|
||||||
posptr->lineno = lineno;
|
posptr->lineno = lineno;
|
||||||
posptr->xno = xpos;
|
posptr->xno = xpos;
|
||||||
|
free(fullpath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
posprev = posptr;
|
posprev = posptr;
|
||||||
|
|
Loading…
Reference in New Issue