From 74364e2afc7378959f7ec7da0872da1939b30883 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Fri, 22 Mar 2024 02:51:11 +0100 Subject: [PATCH] Fix #21641: NPE when creating track iterator from invalid tile element --- distribution/changelog.txt | 1 + src/openrct2/ride/Track.cpp | 3 +++ 2 files changed, 4 insertions(+) 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 {};