Fix assertion error due to too long filenames

This commit is contained in:
Asdow
2024-12-23 20:45:48 +02:00
parent a580052e40
commit c88fbbe749
+9 -1
View File
@@ -173,7 +173,15 @@ void LoadSaveScreenEntry()
vfs::CVirtualProfile* prof = it.value();
memset(&FileInfo, 0, sizeof(GETFILESTRUCT));
strcpy(FileInfo.zFileName, "< ");
strcat(FileInfo.zFileName, prof->cName.utf8().c_str());
// Cut filename off if it's too long for the buffer
if (strlen(prof->cName.utf8().c_str()) > FILENAME_BUFLEN-4)
{
strncpy(FileInfo.zFileName+1, prof->cName.utf8().c_str(), FILENAME_BUFLEN-4);
}
else
{
strcat(FileInfo.zFileName, prof->cName.utf8().c_str());
}
strcat(FileInfo.zFileName, " >");
FileInfo.zFileName[FILENAME_BUFLEN] = 0;
FileInfo.uiFileAttribs = FILE_IS_DIRECTORY;