commit 474b390816c10d75f47b983f599aab5155028c7c
parent b58676f3c98b2f6446f470927143f2e6136d6d97
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 22 Jul 2015 18:02:36 +0000
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
Diffstat:
4 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -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>
* 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
@@ -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
@@ -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
@@ -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);
}