(svn r26058) -Fix: handle the return value of a number of functions better

This commit is contained in:
rubidium
2013-11-23 13:15:07 +00:00
parent b3e93d6520
commit 0e9c992104
10 changed files with 53 additions and 15 deletions

View File

@@ -250,10 +250,9 @@ static SavegameType DetermineOldSavegameType(FILE *f, char *title, const char *l
/* Can't fseek to 0 as in tar files that is not correct */
long pos = ftell(f);
if (!CheckOldSavegameType(f, temp, lastof(temp), TTO_HEADER_SIZE)) {
if (pos >= 0 && !CheckOldSavegameType(f, temp, lastof(temp), TTO_HEADER_SIZE)) {
type = SGT_TTD;
fseek(f, pos, SEEK_SET);
if (!CheckOldSavegameType(f, temp, lastof(temp), TTD_HEADER_SIZE)) {
if (fseek(f, pos, SEEK_SET) < 0 || !CheckOldSavegameType(f, temp, lastof(temp), TTD_HEADER_SIZE)) {
type = SGT_INVALID;
}
}