Fix bounds check in RideGetVehicleColour (#26111)

This commit is contained in:
Aaron van Geffen authored and GitHub committed 2026-03-01 10:44:15 +00:00
1 parent 22ba13e21a
commit 485e882e15
2 files changed
+2 -1

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
0.4.33 (in development)
------------------------------------------------------------------------
- Fix: [#26111] Vehicle colours tab can go out of bounds in certain edge cases.
0.4.32 (2026-03-01)
------------------------------------------------------------------------
+1 -1
View File
@@ -2207,7 +2207,7 @@ std::pair<RideMeasurement*, OpenRCT2String> Ride::getMeasurement()
VehicleColour RideGetVehicleColour(const Ride& ride, int32_t vehicleIndex)
{
// Prevent indexing array out of bounds
vehicleIndex = std::min<int32_t>(vehicleIndex, static_cast<int32_t>(std::size(ride.vehicleColours)));
vehicleIndex = std::clamp<int32_t>(vehicleIndex, 0, std::size(ride.vehicleColours) - 1);
return ride.vehicleColours[vehicleIndex];
}