Fix for #2824798 (FW: crash when clicking "load" in the GUI):

- Fixed CineMetaEngine::listSaves(const char *target) which was broken.
- Also added explicit initialization of savegame descriptions to
  empty strings for safety reasons (e.g. arrays on stack aren't
  initialized to zero).
- Added explicit trailing zero setting to savegame descriptions
  (Previously using GMM you could write a description of length >= 20
  that had no trailing zero when written to description file (e.g. fw.dir)).

svn-id: r43027
This commit is contained in:
Kari Salminen 2009-08-03 17:52:07 +00:00
parent 9931fb6a44
commit c2dc86df08
3 changed files with 42 additions and 22 deletions

View file

@ -468,9 +468,18 @@ bool CineEngine::loadSaveDirectory(void) {
return false;
}
// Initialize all savegames' descriptions to empty strings
// so that if the savegames' descriptions can only be partially read from file
// then the missing ones are correctly set to empty strings.
memset(currentSaveName, 0, sizeof(currentSaveName));
fHandle->read(currentSaveName, 10 * 20);
delete fHandle;
// Make sure all savegames' descriptions end with a trailing zero.
for (int i = 0; i < ARRAYSIZE(currentSaveName); i++)
currentSaveName[i][sizeof(CommandeType) - 1] = 0;
return true;
}