Skip to content

Commit ff8c33e

Browse files
committed
Fix crashes in config menu due to buffer overflows.
1 parent 98ba118 commit ff8c33e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

stm32/src/sm1000_main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -945,11 +945,14 @@ static void menu_default_cb(struct menu_t* const menu, uint32_t event)
945945
break;
946946
case MENU_EVT_PREV:
947947
sfx_play(&sfx_player, sound_click);
948-
menu->current = menu->current - 1;
949-
if (menu->current < 0)
948+
if (menu->current == 0)
950949
{
951950
menu->current = item->num_children - 1;
952951
}
952+
else
953+
{
954+
menu->current = menu->current - 1;
955+
}
953956
announce = 1;
954957
break;
955958
case MENU_EVT_SELECT:
@@ -1002,7 +1005,7 @@ static const struct menu_item_t menu_op_mode = {
10021005
.label = "MODE",
10031006
.event_cb = menu_op_mode_cb,
10041007
.children = menu_op_mode_children,
1005-
.num_children = 3,
1008+
.num_children = 4,
10061009
};
10071010
/* Children */
10081011
static const struct menu_item_t menu_op_mode_analog = {
@@ -1081,11 +1084,14 @@ static void menu_op_mode_cb(struct menu_t* const menu, uint32_t event)
10811084
break;
10821085
case MENU_EVT_PREV:
10831086
sfx_play(&sfx_player, sound_click);
1084-
menu->current = menu->current - 1;
1085-
if (menu->current < 0)
1087+
if (menu->current == 0)
10861088
{
10871089
menu->current = item->num_children - 1;
10881090
}
1091+
else
1092+
{
1093+
menu->current = menu->current - 1;
1094+
}
10891095
announce = 1;
10901096
break;
10911097
case MENU_EVT_SELECT:

0 commit comments

Comments
 (0)