[Scummvm-cvs-logs] SF.net SVN: scummvm: [27484] scummvm/trunk/engines/sword1/control.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sat Jun 16 21:27:06 CEST 2007
Revision: 27484
http://scummvm.svn.sourceforge.net/scummvm/?rev=27484&view=rev
Author: eriktorbjorn
Date: 2007-06-16 12:27:05 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Try to be more robust/paranoid when reading the SAVEGAME.INF file. Apart from
being a sensible precaution, it should work around some bugs like #1737801,
where the file is obviously corrupted. (Possibly mutilated by some file
transfer program.)
Modified Paths:
--------------
scummvm/trunk/engines/sword1/control.cpp
Modified: scummvm/trunk/engines/sword1/control.cpp
===================================================================
--- scummvm/trunk/engines/sword1/control.cpp 2007-06-16 19:26:19 UTC (rev 27483)
+++ scummvm/trunk/engines/sword1/control.cpp 2007-06-16 19:27:05 UTC (rev 27484)
@@ -700,6 +700,9 @@
inf = _saveFileMan->openForLoading("SAVEGAME.INF");
_saveScrollPos = _saveFiles = 0;
_selectedSavegame = 255;
+ for (uint8 cnt = 0; cnt < 64; cnt++) {
+ memset(_saveNames[cnt], 0, sizeof(_saveNames[cnt]));
+ }
if (inf) {
uint8 curFileNum = 0;
uint8 ch;
@@ -707,20 +710,18 @@
uint8 pos = 0;
do {
ch = inf->readByte();
- if ((ch == 10) || (ch == 255))
- _saveNames[curFileNum][pos] = '\0';
- else
- _saveNames[curFileNum][pos] = ch;
- pos++;
- } while ((ch != 10) && (ch != 255));
- curFileNum++;
- } while (ch != 255);
+ if (pos < sizeof(_saveNames[curFileNum]) - 1) {
+ if ((ch == 10) || (ch == 255) || (inf->eos()))
+ _saveNames[curFileNum][pos++] = '\0';
+ else if (ch >= 32)
+ _saveNames[curFileNum][pos++] = ch;
+ }
+ } while ((ch != 10) && (ch != 255) && (!inf->eos()));
+ if (_saveNames[curFileNum][0] != 0)
+ curFileNum++;
+ } while ((ch != 255) && (!inf->eos()));
_saveFiles = curFileNum;
- for (uint8 cnt = _saveFiles; cnt < 64; cnt++)
- _saveNames[cnt][0] = '\0';
- } else
- for (uint8 cnt = 0; cnt < 64; cnt++)
- _saveNames[cnt][0] = '\0';
+ }
delete inf;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list