From cc0803d4664e80bcabec4f806453fac38b02b509 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 3 Nov 2016 18:23:42 +0000 Subject: [PATCH] Prevent crash #4694. Crash in ride_get_entrance with no station Issue is being caused by deleting the station track without removing the station track entry in the ride struct. This will prevent the crash but this should not happen in practice. --- src/ride/ride.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ride/ride.c b/src/ride/ride.c index 6ade1614e0..79817dfe29 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -7239,6 +7239,10 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc entranceMinY = mapY; mapElement = ride_get_station_start_track_element(ride, gRideEntranceExitPlaceStationIndex); + if (mapElement == NULL) { + *outX = 0x8000; + return; + } direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; stationDirection = direction;