diff --git a/distribution/changelog.txt b/distribution/changelog.txt index a3ebe2a45c..9b8a275719 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -7,6 +7,7 @@ - Fix: [#910] Extra viewport does not preserve the location when rotating. - Fix: [#21434] Number of guests overflows in objective text. - Fix: [#21543] Crash with creating a TrackIterator with invalid arguments. +- Fix: [#21641] Crash when creating track iterator from an invalid tile element. 0.4.9 (2024-03-02) ------------------------------------------------------------------------ diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 113e00fa92..f633875149 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -733,6 +733,9 @@ bool TrackTypeIsHelix(track_type_t trackType) std::optional GetTrackSegmentOrigin(const CoordsXYE& posEl) { + if (posEl.element == nullptr) + return {}; + auto trackEl = posEl.element->AsTrack(); if (trackEl == nullptr) return {};