Skip to content

Commit

Permalink
IOP HLE: Only track handles to valid files.
Browse files Browse the repository at this point in the history
Bonus check for file validity when saving states.
  • Loading branch information
F0bes committed Oct 8, 2024
1 parent 324b146 commit 1c1f67c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pcsx2/IopBios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,17 @@ namespace R3000A
v0 = allocfd(file);
if ((s32)v0 < 0)
file->close();
else
{
fileHandle handle;
handle.fd_index = v0 - firstfd;
handle.flags = flags;
handle.full_path = path;
handle.mode = mode;
handles.push_back(handle);
}
}

fileHandle handle;
handle.fd_index = v0 - firstfd;
handle.flags = flags;
handle.full_path = path;
handle.mode = mode;
handles.push_back(handle);

pc = ra;
return 1;
}
Expand Down Expand Up @@ -1463,7 +1465,7 @@ bool SaveStateBase::handleFreeze()
//save the current file position
const u32 fd = R3000A::handles[i].fd_index;
IOManFile* file = R3000A::ioman::getfd<IOManFile>(fd + firstfd);
s32 pos = file->lseek(0, SEEK_CUR);
s32 pos = file ? file->lseek(0, SEEK_CUR) : 0;
Freeze(pos);

//save the parameters for opening the file
Expand Down

0 comments on commit 1c1f67c

Please sign in to comment.