mirror of
https://github.com/labwc/labwc.git
synced 2026-04-21 06:46:53 -04:00
menu: prevent memory leak when cycling through menu items
This commit is contained in:
parent
eba57831f4
commit
667707c029
1 changed files with 5 additions and 1 deletions
|
|
@ -1475,7 +1475,7 @@ bool
|
||||||
menu_item_select_by_accelerator(char accelerator)
|
menu_item_select_by_accelerator(char accelerator)
|
||||||
{
|
{
|
||||||
struct menu *menu = get_selection_leaf();
|
struct menu *menu = get_selection_leaf();
|
||||||
if (!menu) {
|
if (!menu || wl_list_empty(&menu->menuitems)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1489,6 +1489,10 @@ menu_item_select_by_accelerator(char accelerator)
|
||||||
struct menuitem *next_selection = NULL;
|
struct menuitem *next_selection = NULL;
|
||||||
do {
|
do {
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
if (current == &menu->menuitems) {
|
||||||
|
/* Allow wrap around */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
item = wl_container_of(current, item, link);
|
item = wl_container_of(current, item, link);
|
||||||
if (item->accelerator == accelerator) {
|
if (item->accelerator == accelerator) {
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue