From: Benno Schulenberg Date: Wed, 22 Jul 2015 18:02:36 +0000 (+0000) Subject: Plugging a few memory leaks. X-Git-Tag: v2.5.0~148 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=474b390816c10d75f47b983f599aab5155028c7c;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index ee485fb6..772b4220 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-07-22 Mike Frysinger + * 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 * src/nano.c (main): Accept again a +LINE argument for each file given on the command line. This fixes Savannah bug #45576. diff --git a/src/files.c b/src/files.c index 3c417b7f..55e330bb 100644 --- a/src/files.c +++ b/src/files.c @@ -2952,6 +2952,7 @@ void history_error(const char *msg, ...) * successfully created, and return 0 otherwise. */ int check_dotnano(void) { + int ret = 1; struct stat dirstat; char *nanodir = construct_filename("/.nano"); @@ -2960,15 +2961,17 @@ int check_dotnano(void) history_error(N_("Unable to create directory %s: %s\n" "It is required for saving/loading search history or cursor positions.\n"), nanodir, strerror(errno)); - return 0; + ret = 0; } } else if (!S_ISDIR(dirstat.st_mode)) { 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"), nanodir); - return 0; + ret = 0; } - return 1; + + free(nanodir); + return ret; } /* Load the search and replace histories from ~/.nano/search_history. */ diff --git a/src/global.c b/src/global.c index 209fc4e8..4e28e7a1 100644 --- a/src/global.c +++ b/src/global.c @@ -1613,6 +1613,8 @@ void thanks_for_all_the_fish(void) syntaxtype *bill = syntaxes; free(syntaxes->desc); + free(syntaxes->linter); + free(syntaxes->formatter); while (syntaxes->extensions != NULL) { regexlisttype *bob = syntaxes->extensions; syntaxes->extensions = bob->next; diff --git a/src/rcfile.c b/src/rcfile.c index f07e80ca..2f933233 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -571,7 +571,8 @@ void parse_binding(char *ptr, bool dobind) /* Add the new shortcut at the start of the list. */ newsc->next = sclist; sclist = newsc; - } + } else + free(keycopy); }