From c9b5ec4172668781f5b4cf7d2862e08cda27e290 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 24 Jun 2017 17:44:30 +0200 Subject: [PATCH] Guard against NULL ObjectRepositoryItem, fixes #5614 --- src/openrct2/ride/TrackDesignRepository.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/openrct2/ride/TrackDesignRepository.cpp b/src/openrct2/ride/TrackDesignRepository.cpp index 408e70021d..a681c87139 100644 --- a/src/openrct2/ride/TrackDesignRepository.cpp +++ b/src/openrct2/ride/TrackDesignRepository.cpp @@ -119,7 +119,7 @@ public: { const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str()); - if (gConfigInterface.select_by_track_type || !(ori->RideFlags & ORI_RIDE_FLAG_SEPARATE)) + if (gConfigInterface.select_by_track_type || ori == nullptr || !(ori->RideFlags & ORI_RIDE_FLAG_SEPARATE)) entryIsNotSeparate = true; } @@ -144,7 +144,8 @@ public: } const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str()); - ride_group * itemRideGroup = ride_group_find(rideType, ori->RideGroupIndex); + uint8 rideGroupIndex = (ori != nullptr) ? ori->RideGroupIndex : 0; + ride_group * itemRideGroup = ride_group_find(rideType, rideGroupIndex); if (itemRideGroup != NULL && ride_groups_are_equal(itemRideGroup, rideGroup)) { @@ -179,7 +180,7 @@ public: { const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str()); - if (gConfigInterface.select_by_track_type || !(ori->RideFlags & ORI_RIDE_FLAG_SEPARATE)) + if (gConfigInterface.select_by_track_type || ori == nullptr || !(ori->RideFlags & ORI_RIDE_FLAG_SEPARATE)) entryIsNotSeparate = true; } @@ -209,7 +210,8 @@ public: } const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str()); - ride_group * itemRideGroup = ride_group_find(rideType, ori->RideGroupIndex); + uint8 rideGroupIndex = (ori != nullptr) ? ori->RideGroupIndex : 0; + ride_group * itemRideGroup = ride_group_find(rideType, rideGroupIndex); if (itemRideGroup != NULL && ride_groups_are_equal(itemRideGroup, rideGroup)) {