Plugging a few memory leaks.

Patch by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5314 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-07-22 18:02:36 +00:00
parent b58676f3c9
commit 474b390816
4 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2015-07-22 Mike Frysinger <vapier@gentoo.org>
* src/files.c (check_dotnano), src/global.c (thanks_for_all_the_fish),
src/rcfile.c (parse_binding): Plug a few memory leaks.
2015-07-19 Benno Schulenberg <bensberg@justemail.net> 2015-07-19 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): Accept again a +LINE argument for each file * src/nano.c (main): Accept again a +LINE argument for each file
given on the command line. This fixes Savannah bug #45576. given on the command line. This fixes Savannah bug #45576.

View File

@ -2952,6 +2952,7 @@ void history_error(const char *msg, ...)
* successfully created, and return 0 otherwise. */ * successfully created, and return 0 otherwise. */
int check_dotnano(void) int check_dotnano(void)
{ {
int ret = 1;
struct stat dirstat; struct stat dirstat;
char *nanodir = construct_filename("/.nano"); char *nanodir = construct_filename("/.nano");
@ -2960,15 +2961,17 @@ int check_dotnano(void)
history_error(N_("Unable to create directory %s: %s\n" history_error(N_("Unable to create directory %s: %s\n"
"It is required for saving/loading search history or cursor positions.\n"), "It is required for saving/loading search history or cursor positions.\n"),
nanodir, strerror(errno)); nanodir, strerror(errno));
return 0; ret = 0;
} }
} else if (!S_ISDIR(dirstat.st_mode)) { } else if (!S_ISDIR(dirstat.st_mode)) {
history_error(N_("Path %s is not a directory and needs to be.\n" history_error(N_("Path %s is not a directory and needs to be.\n"
"Nano will be unable to load or save search history or cursor positions.\n"), "Nano will be unable to load or save search history or cursor positions.\n"),
nanodir); nanodir);
return 0; ret = 0;
} }
return 1;
free(nanodir);
return ret;
} }
/* Load the search and replace histories from ~/.nano/search_history. */ /* Load the search and replace histories from ~/.nano/search_history. */

View File

@ -1613,6 +1613,8 @@ void thanks_for_all_the_fish(void)
syntaxtype *bill = syntaxes; syntaxtype *bill = syntaxes;
free(syntaxes->desc); free(syntaxes->desc);
free(syntaxes->linter);
free(syntaxes->formatter);
while (syntaxes->extensions != NULL) { while (syntaxes->extensions != NULL) {
regexlisttype *bob = syntaxes->extensions; regexlisttype *bob = syntaxes->extensions;
syntaxes->extensions = bob->next; syntaxes->extensions = bob->next;

View File

@ -571,7 +571,8 @@ void parse_binding(char *ptr, bool dobind)
/* Add the new shortcut at the start of the list. */ /* Add the new shortcut at the start of the list. */
newsc->next = sclist; newsc->next = sclist;
sclist = newsc; sclist = newsc;
} } else
free(keycopy);
} }