Skip to content

Commit

Permalink
misc: avoid assertion failure when state save fails
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Dec 10, 2023
1 parent 96867f0 commit 8338889
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libpcsxcore/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ int SaveState(const char *file) {
assert(!psxRegs.branching);
assert(!psxRegs.cpuInRecursion);
assert(!misc->magic);

f = SaveFuncs.open(file, "wb");
if (f == NULL) return -1;

misc->magic = MISC_MAGIC;
misc->gteBusyCycle = psxRegs.gteBusyCycle;
misc->muldivBusyCycle = psxRegs.muldivBusyCycle;
Expand All @@ -687,9 +691,6 @@ int SaveState(const char *file) {
misc->frame_counter = frame_counter;
misc->CdromFrontendId = CdromFrontendId;

f = SaveFuncs.open(file, "wb");
if (f == NULL) return -1;

psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL);

SaveFuncs.write(f, (void *)PcsxHeader, 32);
Expand Down

0 comments on commit 8338889

Please sign in to comment.