Skip to content

Commit 616efff

Browse files
committed
Handle null save-state paths
1 parent 0efba78 commit 616efff

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/GearsystemCore.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,19 @@ void GearsystemCore::LoadRam(const char* szPath, bool fullPath)
672672
std::string GearsystemCore::GetSaveStatePath(const char* path, int index)
673673
{
674674
if (index < 0)
675-
return path;
675+
{
676+
if (IsValidPointer(path))
677+
return path;
678+
679+
using namespace std;
680+
string full_path = m_pCartridge->GetFilePath();
681+
string::size_type dot_index = full_path.rfind('.');
682+
683+
if (dot_index != string::npos)
684+
full_path.replace(dot_index + 1, full_path.length() - dot_index - 1, "state");
685+
686+
return full_path;
687+
}
676688

677689
using namespace std;
678690
string full_path;

0 commit comments

Comments
 (0)