OpenTTD/OpenTTD

[Bug]: Timer period modifications may violate invariants of TimerManager::base_timer_sorter std::set sorting

Closed this issue · 0 comments

Version of OpenTTD

master

Expected result

Invariants are always maintained, etc

Actual result

TimeoutTimer::Reset(const TPeriod timeout), IntervalTimer::SetInterval and savegame load of _new_competitor_timeout.period can directly change the BaseTimer::period field of timers which are already in the TimerManager std::set, which uses TimerManager::base_timer_sorter. This can violate the ordering invariants of std::set, which may result in undefined behaviour.

Steps to reproduce

See src/timer/.