From 1c1f67c091f15a699efad9c3a006ced41f20c5ab Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Tue, 8 Oct 2024 17:23:04 -0400 Subject: [PATCH] IOP HLE: Only track handles to valid files. Bonus check for file validity when saving states. --- pcsx2/IopBios.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 742e56be0ab19..5c4e770ad4312 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -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(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