1
1

memory: avoid a leak when a string bind specifies an unknown menu

(It is a harmless leak, but LeakSanitizer is loud when it complains.)

After having determined that there is a menu name, first check that
it is valid, before processing the string or the function name.

This fixes https://savannah.gnu.org/bugs/?62991.

Problem existed since version 2.9.4, since string binds were introduced.
Этот коммит содержится в:
Benno Schulenberg 2022-08-31 16:20:29 +02:00
родитель ccabaac5a0
Коммит 97fa42c82b

Просмотреть файл

@ -787,6 +787,12 @@ void parse_binding(char *ptr, bool dobind)
goto free_things;
}
menu = name_to_menu(menuptr);
if (menu < 1) {
jot_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
goto free_things;
}
if (dobind) {
/* If the thing to bind starts with a double quote, it is a string,
* otherwise it is the name of a function. */
@ -806,12 +812,6 @@ void parse_binding(char *ptr, bool dobind)
}
}
menu = name_to_menu(menuptr);
if (menu < 1) {
jot_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
goto free_things;
}
/* Wipe the given shortcut from the given menu. */
for (keystruct *s = sclist; s != NULL; s = s->next)
if ((s->menus & menu) && s->keycode == keycode)