IOP HLE: Only track handles to valid files.

Bonus check for file validity when saving states.
This commit is contained in:
Ty Lamontagne 2024-10-08 17:23:04 -04:00 committed by Ty
parent 324b1464e4
commit 1c1f67c091
1 changed files with 10 additions and 8 deletions

View File

@ -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;
}
@ -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