menu: prevent memory leak when cycling through menu items

This commit is contained in:
Alex Chernika 2026-04-11 16:46:41 +02:00
parent eba57831f4
commit 667707c029
No known key found for this signature in database
GPG key ID: 6029FAD8ABFB076A

View file

@ -1475,7 +1475,7 @@ bool
menu_item_select_by_accelerator(char accelerator)
{
struct menu *menu = get_selection_leaf();
if (!menu) {
if (!menu || wl_list_empty(&menu->menuitems)) {
return false;
}
@ -1489,6 +1489,10 @@ menu_item_select_by_accelerator(char accelerator)
struct menuitem *next_selection = NULL;
do {
current = current->next;
if (current == &menu->menuitems) {
/* Allow wrap around */
continue;
}
item = wl_container_of(current, item, link);
if (item->accelerator == accelerator) {
if (!matched) {