Closed shantonusen closed 3 years ago
I have no idea what that -1 was doing there. Using blame, 6a247cbe8b6bba817d664a948ca90a88f2d76772 is the culprit, where I changed the track travelling information from accepting a pointer to a track object, to instead accepting a list of checkpoints. There was no change in the way it iterates or makes use of the list of checkpoints/body parts, so I've got no clue as to why that weird -1 was added. Thanks for the correction!
The attached area ride-track.zip and track item Climbing_stick_inc_leader.zip demonstrates a crash I've run into. If you move the leader to the base of the climbing stick, or throw a Pikmin to the base of the climbing stick, you'll get an Asan crash like the following respectively:
If I throw a Pikmin, it's basically the same:
Both of these crashes happen in
mob::tick_track_ride
when a vector is indexed past its boundsThis code expects to access both start and end checkpoints, but the array only has one entry, so
track_info->checkpoints[track_info->cur_cp_nr + 1]
results in a read past the end of the vector.I see an assertion that a track type has >=2 parts
I believe the problem here is an off-by-one error when copying the track parts
If this is copying the checkpoints from the track, it's not conventional to use
<
and alsosize() - 1
. This would create acheckpoints
vector of size 1 for the track, when the assertion during loading is that it's>=2
and the runtime code inmob::tick_track_ride()
assumes it can access the next checkpoint. Changing thesize() - 1
-> size()` fixes this for both leaders and Pikmin, and they now smoothly go up the track and hop off the end.