* 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.
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. */
keycopy[2] = toupper(keycopy[2]);
else {
rcfile_error(N_("Key name is too short"));
- return;
+ goto free_copy;
}
}
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) {
if (funcptr[0] == '\0') {
rcfile_error(N_("Must specify a function to bind the key to"));
- return;
+ goto free_copy;
}
}
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
if (!menu) {
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
free(newsc);
- return;
+ goto free_copy;
}
newsc->keystr = keycopy;
if (check_bad_binding(newsc)) {
rcfile_error(N_("Sorry, keystroke \"%s\" may not be rebound"), newsc->keystr);
free(newsc);
- return;
+ goto free_copy;
}
}
/* Add the new shortcut at the start of the list. */
newsc->next = sclist;
sclist = newsc;
- } else
- free(keycopy);
+ return;
+ }
+
+ free_copy:
+ free(keycopy);
}