From 3a47e3b309e7adfc1bc58315beffed167c290f25 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Wed, 1 Apr 2020 12:45:08 +0200 Subject: [PATCH] Fix #11166: Null pointer read in Guest::UpdateRideAdvanceThroughEntrance (#11182) --- src/openrct2/peep/Guest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index cd6c586b92..d81e728352 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -3728,9 +3728,18 @@ void Guest::UpdateRideAdvanceThroughEntrance() } Vehicle* vehicle = GET_VEHICLE(ride->vehicles[current_train]); + if (vehicle == nullptr) + { + return; + } + for (int32_t i = current_car; i != 0; --i) { vehicle = GET_VEHICLE(vehicle->next_vehicle_on_train); + if (vehicle == nullptr) + { + return; + } } ride_entry = get_ride_entry(vehicle->ride_subtype);