Fix #21543: Game Crashing with invalid TrackIterator (#21547)

* Check if el is nullptr

Check if el is nullptr

Format

* Add changelog
This commit is contained in:
Harry Hopkinson 2024-03-09 14:15:28 +00:00 committed by GitHub
parent 048276b67a
commit 0c1fb5fec0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@
------------------------------------------------------------------------
- Improved: [#21424] Extra viewports can now rotate independently from the main viewport.
- Fix: [#910] Extra viewport does not preserve the location when rotating.
- Fix: [#21543] Crash with creating a TrackIterator with invalid arguments.
0.4.9 (2024-03-02)
------------------------------------------------------------------------

View File

@ -23,6 +23,8 @@ using namespace OpenRCT2::TrackMetaData;
std::shared_ptr<ScTrackIterator> ScTrackIterator::FromElement(const CoordsXY& position, int32_t elementIndex)
{
auto el = MapGetNthElementAt(position, elementIndex);
if (el == nullptr)
return nullptr;
auto origin = GetTrackSegmentOrigin(CoordsXYE(position, el));
if (!origin)
return nullptr;