From d3e9543feeb495729739433f6b8577f922a6051b Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Tue, 17 Jul 2018 18:55:03 +0200 Subject: [PATCH] Fix undefined behaviour Argument evaluation order is undefined --- Firmware/menu.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/menu.cpp b/Firmware/menu.cpp index 17292930..ab7a60ab 100644 --- a/Firmware/menu.cpp +++ b/Firmware/menu.cpp @@ -75,7 +75,10 @@ void menu_end(void) void menu_back(void) { - if (menu_depth > 0) menu_goto(menu_stack[--menu_depth].menu, menu_stack[menu_depth].position, true, true); + if (menu_depth > 0) { + menu_depth--; + menu_goto(menu_stack[menu_depth].menu, menu_stack[menu_depth].position, true, true); + } } void menu_back_if_clicked(void)