From e454f27518949b02471a906dbbb0a86eb1af5fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 21 Jan 2025 12:00:24 +0200 Subject: [PATCH] Fix #23655: Crash with invalid widget index --- src/openrct2-ui/input/MouseInput.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 85c6eb1deb..79b5faca71 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -290,7 +290,7 @@ namespace OpenRCT2 // Get window and widget under cursor position w = windowMgr->FindFromPoint(screenCoords); - widgetIndex = w == nullptr ? -1 : windowMgr->FindWidgetFromPoint(*w, screenCoords); + widgetIndex = w == nullptr ? kWidgetIndexNull : windowMgr->FindWidgetFromPoint(*w, screenCoords); widget = widgetIndex == kWidgetIndexNull ? nullptr : &w->widgets[widgetIndex]; switch (_inputState) @@ -1557,7 +1557,8 @@ namespace OpenRCT2 { if (gTooltipCursor == screenCoords) { - if (gCurrentRealTimeTicks >= _tooltipNotShownTimeout && w != nullptr && WidgetIsVisible(*w, widgetIndex)) + if (gCurrentRealTimeTicks >= _tooltipNotShownTimeout && w != nullptr && widgetIndex != kWidgetIndexNull + && WidgetIsVisible(*w, widgetIndex)) { gTooltipCloseTimeout = gCurrentRealTimeTicks + 8000; WindowTooltipOpen(w, widgetIndex, screenCoords);