From e1a1560fd2a0166e0b7f6cacd5d121e1c63274ad Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Tue, 9 Nov 2021 19:41:33 +0100 Subject: [PATCH] Fix #15878: Crash when opening ride window for corrupted vehicle --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Ride.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 56e32570c5..090f52f2e2 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -4,6 +4,7 @@ - Fix: [#15620] Placing track designs at locations blocked by anything results in wrong error message. - Fix: [#15843] Tile Inspector can be resized too small. - Fix: [#15844] Tile Inspector has inconsistent text colours. +- Fix: [#15878] Crash when opening a ride window for a corrupted vehicle. 0.3.5 (2021-11-06) ------------------------------------------------------------------------ diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 069f165731..58ec57ca6d 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1394,7 +1394,13 @@ rct_window* window_ride_open_track(TileElement* tileElement) */ rct_window* window_ride_open_vehicle(Vehicle* vehicle) { + if (vehicle == nullptr) + return nullptr; + Vehicle* headVehicle = vehicle->TrainHead(); + if (headVehicle == nullptr) + return nullptr; + uint16_t headVehicleSpriteIndex = headVehicle->sprite_index; auto ride = headVehicle->GetRide(); if (ride == nullptr)