1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Fix #17921: NPE in track_block_get_next() (#17922)

This commit is contained in:
Michael Steenbeek
2022-08-28 23:46:50 +02:00
committed by GitHub
parent a2f3ab84cc
commit 6c54bacd41

View File

@@ -557,7 +557,16 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32
if (trackBlock == nullptr)
return false;
trackBlock += inputElement->GetSequenceIndex();
// The sequence index may be higher than the amount of sequences actually present.
// We dont know the amount of sequences present in the block upfront, but there is an end marker consisting of all 255s.
const auto sequenceIndex = inputElement->GetSequenceIndex();
for (auto i = 0; i < sequenceIndex; i++)
{
trackBlock++;
if (trackBlock == nullptr || trackBlock->index == 255)
return false;
}
const auto& trackCoordinate = ted.Coordinates;