Fix #11068: segfault when trying to clear empty list (#11069)

The report in #11068 was using track designs manager with "Boat hire"
ride, for which there were no designs and selecting "Clear" button on
the list accessed empty vector in `_filteredTrackIds`.
This commit is contained in:
Michał Janiszewski 2020-03-26 23:49:10 +01:00 committed by GitHub
parent 5276ce767a
commit 56e6ec2c23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -337,7 +337,10 @@ static void window_track_list_mouseup(rct_window* w, rct_widgetindex widgetIndex
// Keep the highlighted item selected
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
{
w->selected_list_item = _filteredTrackIds[w->selected_list_item];
if (w->selected_list_item != -1 && _filteredTrackIds.size() > static_cast<size_t>(w->selected_list_item))
w->selected_list_item = _filteredTrackIds[w->selected_list_item];
else
w->selected_list_item = -1;
}
else
{