Fix off-by-one error in savestates that could cause crashes

This commit is contained in:
PabloMK7 2025-04-24 15:02:09 +02:00
parent 975ad17442
commit b393bf0168

View file

@ -1614,6 +1614,9 @@ void GMainWindow::UpdateSaveStates() {
}
}
for (const auto& savestate : savestates) {
if (savestate.slot >= Core::SaveStateSlotCount) {
continue;
}
const bool display_name =
savestate.status == Core::SaveStateInfo::ValidationStatus::RevisionDismatch &&
!savestate.build_name.empty();
@ -1654,7 +1657,7 @@ void GMainWindow::UpdateSaveStates() {
for (u32 i = 1; i < Core::SaveStateSlotCount; ++i) {
if (!actions_load_state[i]->isEnabled()) {
// Prefer empty slot
oldest_slot = i + 1;
oldest_slot = i;
oldest_slot_time = 0;
break;
}