commit 95e1f55574fa3b809f349bece413cb8b36d7adfd
parent 455fb4f063826fbc71d43cecbf860ea8dfe61ea9
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 3 Aug 2015 19:52:48 +0000
Plugging a tiny leak.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5341 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -2,6 +2,7 @@
* src/rcfile.c (parse_binding): Check the value of shortcut->toggle
only if it actually is a toggle. Found with valgrind.
* src/files.c (write_lockfile): Plug a leak. Found with valgrind.
+ * src/rcfile.c (parse_binding): Plug a tiny leak.
2015-08-02 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (initialize_buffer): Initialize also openfile->syntax.
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -444,7 +444,7 @@ void parse_binding(char *ptr, bool dobind)
if (strlen(keycopy) < 2) {
rcfile_error(N_("Key name is too short"));
- return;
+ goto free_copy;
}
/* Uppercase only the first two or three characters of the key name. */
@@ -455,7 +455,7 @@ void parse_binding(char *ptr, bool dobind)
keycopy[2] = toupper(keycopy[2]);
else {
rcfile_error(N_("Key name is too short"));
- return;
+ goto free_copy;
}
}
@@ -465,7 +465,7 @@ void parse_binding(char *ptr, bool dobind)
keycopy[1] = tolower(keycopy[1]);
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
- return;
+ goto free_copy;
}
if (dobind) {
@@ -474,7 +474,7 @@ void parse_binding(char *ptr, bool dobind)
if (funcptr[0] == '\0') {
rcfile_error(N_("Must specify a function to bind the key to"));
- return;
+ goto free_copy;
}
}
@@ -484,21 +484,21 @@ void parse_binding(char *ptr, bool dobind)
if (menuptr[0] == '\0') {
/* TRANSLATORS: Do not translate the word "all". */
rcfile_error(N_("Must specify a menu (or \"all\") in which to bind/unbind the key"));
- return;
+ goto free_copy;
}
if (dobind) {
newsc = strtosc(funcptr);
if (newsc == NULL) {
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
- return;
+ goto free_copy;
}
}
menu = strtomenu(menuptr);
if (menu < 1) {
rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
- return;
+ goto free_copy;
}
#ifdef DEBUG
@@ -531,7 +531,7 @@ void parse_binding(char *ptr, bool dobind)
if (!menu) {
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
free(newsc);
- return;
+ goto free_copy;
}
newsc->keystr = keycopy;
@@ -546,7 +546,7 @@ void parse_binding(char *ptr, bool dobind)
if (check_bad_binding(newsc)) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
free(newsc);
- return;
+ goto free_copy;
}
}
@@ -571,8 +571,11 @@ 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);
+ return;
+ }
+
+ free_copy:
+ free(keycopy);
}