Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core/State: Refactor logic for determining the relative age of existing savestates. #12262

Merged
merged 2 commits into from Oct 31, 2023

Conversation

AdmiralCurtiss
Copy link
Contributor

Plus another minor robustness issue I ran into while testing. Turns out localtime() can return a nullptr, and wcsftime() asserts if you pass it one.

I noticed this back when reviewing #12217. The code previously did this indirectly via std::map<double, int>, the key being the timestamp, which required a questionable workaround for the case where multiple states have the same timestamp. By having a particular combination of timestamps in the on-disk savestates, you could cause this workaround to infinitely loop, locking up Dolphin. This avoids this completely by refactoring the logic and just using std::vector instead.

Admittedly, this is pretty difficult to trigger by accident, but if you just manually edit two states to have eg. 1e300 as the timestamp this triggers, because incrementing a double of such magnitude by 0.001 just results in the same double again.

…ng savestates.

The code previously did this indirectly via `std::map<double, int>`, the key being the timestamp, which required a questionable workaround for the case where multiple states have the same timestamp. By having a particular combination of timestamps in the on-disk savestates, you could cause this workaround to infinitely loop, locking up Dolphin. This avoids this completely by refactoring the logic and just using `std::vector` instead.
@JosJuice JosJuice merged commit b32ac93 into dolphin-emu:master Oct 31, 2023
11 checks passed
@AdmiralCurtiss AdmiralCurtiss deleted the last-state-order-refactor branch October 31, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants