From 9af617c8eeea2e0e2fcc28b526d21251b746e522 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 3 Jun 2024 00:45:39 +1000 Subject: [PATCH 1/2] ui/selmenu.cpp: Fixed out-of-bounds access when no primary items are visible (fixes GitHub #12429). Also fixed separator being highlighted as though it were selectable. --- src/devices/cpu/mipsx/mipsxdasm.h | 2 +- src/frontend/mame/ui/selgame.cpp | 4 ++-- src/frontend/mame/ui/selmenu.cpp | 37 +++++++++++++++++-------------- src/frontend/mame/ui/selsoft.cpp | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/devices/cpu/mipsx/mipsxdasm.h b/src/devices/cpu/mipsx/mipsxdasm.h index dd8e5562bf3..a6e1fe7d092 100644 --- a/src/devices/cpu/mipsx/mipsxdasm.h +++ b/src/devices/cpu/mipsx/mipsxdasm.h @@ -16,4 +16,4 @@ class mipsx_disassembler : public util::disasm_interface virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) override; }; -#endif +#endif // MAME_CPU_MIPSX_MIPSXDASM_H diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index e9cc85e9a43..dda281f684a 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -196,7 +196,7 @@ void menu_select_game::menu_deactivated() bool menu_select_game::handle(event const *ev) { - if (!m_prev_selected && item_count() > 0) + if (!m_prev_selected && (item_count() > 0)) m_prev_selected = item(0).ref(); // if I have to select software, force software list submenu @@ -405,7 +405,7 @@ void menu_select_game::populate() item_append(_("System Settings"), 0, (void *)(uintptr_t)CONF_MACHINE); m_skip_main_items = 3; - if (m_prev_selected && !have_prev_selected && item_count() > 0) + if (m_prev_selected && !have_prev_selected && (item_count() > 0)) m_prev_selected = item(0).ref(); } else diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index ec24de179e7..ee823f12d8e 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -2598,7 +2598,7 @@ std::tuple menu_select_launch::handle_middle_down(bool changed, { // left panel assert(show_left_panel()); - if ((get_focus() == focused_menu::MAIN) && (selected_index() <= m_available_items)) + if ((get_focus() == focused_menu::MAIN) && (selected_index() < m_available_items)) m_prev_selected = get_selection_ref(); set_focus(focused_menu::LEFT); return std::make_tuple(IPT_INVALID, true, true); @@ -2607,7 +2607,7 @@ std::tuple menu_select_launch::handle_middle_down(bool changed, { // right panel assert(show_right_panel()); - if ((get_focus() == focused_menu::MAIN) && (selected_index() <= m_available_items)) + if ((get_focus() == focused_menu::MAIN) && (selected_index() < m_available_items)) m_prev_selected = get_selection_ref(); set_focus((y < m_right_tabs_bottom) ? focused_menu::RIGHTTOP : focused_menu::RIGHTBOTTOM); return std::make_tuple(IPT_INVALID, true, true); @@ -3157,7 +3157,7 @@ bool menu_select_launch::main_force_visible_selection() return true; } } - else + else if (m_prev_selected) { int selection(0); while ((m_available_items > selection) && (item(selection).ref() != m_prev_selected)) @@ -3366,8 +3366,6 @@ void menu_select_launch::draw(u32 flags) // work out colours rgb_t fgcolor = ui().colors().text_color(); rgb_t bgcolor = ui().colors().text_bg_color(); - bool const hovered(is_selectable(pitem) && pointer_in_rect(m_primary_items_hbounds.first, linetop, m_primary_items_hbounds.second, linebottom)); - bool const pointerline((pointer_action::MAIN_TRACK_LINE == m_pointer_action) && ((m_primary_lines + linenum) == m_clicked_line)); if (is_selected(itemnum) && (get_focus() == focused_menu::MAIN)) { // if we're selected, draw with a different background @@ -3379,19 +3377,24 @@ void menu_select_launch::draw(u32 flags) bgcolor, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); } - else if (pointerline && hovered) - { - // draw selected highlight for tracked item - fgcolor = ui().colors().selected_color(); - bgcolor = ui().colors().selected_bg_color(); - highlight(m_primary_items_hbounds.first, linetop, m_primary_items_hbounds.second, linebottom, bgcolor); - } - else if (pointerline || (!m_ui_error && !(flags & PROCESS_NOINPUT) && hovered && pointer_idle())) + else if (is_selectable(pitem)) { - // draw hover highlight when hovered over or dragged off - fgcolor = ui().colors().mouseover_color(); - bgcolor = ui().colors().mouseover_bg_color(); - highlight(m_primary_items_hbounds.first, linetop, m_primary_items_hbounds.second, linebottom, bgcolor); + bool const hovered(pointer_in_rect(m_primary_items_hbounds.first, linetop, m_primary_items_hbounds.second, linebottom)); + bool const pointerline((pointer_action::MAIN_TRACK_LINE == m_pointer_action) && ((m_primary_lines + linenum) == m_clicked_line)); + if (pointerline && hovered) + { + // draw selected highlight for tracked item + fgcolor = ui().colors().selected_color(); + bgcolor = ui().colors().selected_bg_color(); + highlight(m_primary_items_hbounds.first, linetop, m_primary_items_hbounds.second, linebottom, bgcolor); + } + else if (pointerline || (!m_ui_error && !(flags & PROCESS_NOINPUT) && hovered && pointer_idle())) + { + // draw hover highlight when hovered over or dragged off + fgcolor = ui().colors().mouseover_color(); + bgcolor = ui().colors().mouseover_bg_color(); + highlight(m_primary_items_hbounds.first, linetop, m_primary_items_hbounds.second, linebottom, bgcolor); + } } if (pitem.type() == menu_item_type::SEPARATOR) diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index 5a0a4f1eb87..3fb2167dd85 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -424,7 +424,7 @@ menu_select_software::~menu_select_software() bool menu_select_software::handle(event const *ev) { - if (m_prev_selected == nullptr && item_count() > 0) + if (!m_prev_selected && (item_count() > 0)) m_prev_selected = item(0).ref(); // FIXME: everything above here used run before events were processed From 6879ad70c491e08127d2b26491a665cf414ef077 Mon Sep 17 00:00:00 2001 From: angelosa Date: Sun, 2 Jun 2024 17:02:59 +0200 Subject: [PATCH 2/2] sega/naomigd.cpp: fix -validate --- src/mame/sega/naomigd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mame/sega/naomigd.cpp b/src/mame/sega/naomigd.cpp index b67ae0c1183..57dbf3ecd0c 100644 --- a/src/mame/sega/naomigd.cpp +++ b/src/mame/sega/naomigd.cpp @@ -1141,11 +1141,11 @@ ROM_START( dimm ) ROMX_LOAD( "217_203.bin", 0x000000, 0x200000, CRC(a738ea1c) SHA1(e5a229ae7ed48b2955cad63529fd938c6db555e5), ROM_BIOS(4)) ROM_SYSTEM_BIOS(5, "3.01", "BIOS 5") ROMX_LOAD( "fpr23905c.ic36", 0x000000, 0x200000, CRC(ffffffff) SHA1(972b3b73aa1eabb1091e9096b57a7e5e1d0436d8), ROM_BIOS(5)) - ROM_SYSTEM_BIOS(5, "3.03", "BIOS 6") + ROM_SYSTEM_BIOS(6, "3.03", "BIOS 6") ROMX_LOAD( "fpr23905.ic36", 0x000000, 0x200000, CRC(ffffffff) SHA1(acade4362807c7571b1c2a48ed6067e4bddd404b), ROM_BIOS(6)) - ROM_SYSTEM_BIOS(6, "317_312.bin", "BIOS 7") + ROM_SYSTEM_BIOS(7, "317_312.bin", "BIOS 7") ROMX_LOAD( "317_312.bin", 0x000000, 0x200000, CRC(a738ea1c) SHA1(31d698cd659446ee09a2eeedec6e4bc6a19d05e8), ROM_BIOS(7)) - ROM_SYSTEM_BIOS(7, "401_203.bin", "BIOS 8") + ROM_SYSTEM_BIOS(8, "401_203.bin", "BIOS 8") ROMX_LOAD( "401_203.bin", 0x000000, 0x200000, CRC(a738ea1c) SHA1(edb52597108462bcea8eb2a47c19e51e5fb60638), ROM_BIOS(8)) // dynamically filled with data