From 0e9c9921040a1d0e2aa4b820b20535f40a0d75a3 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 23 Nov 2013 13:15:07 +0000 Subject: (svn r26058) -Fix: handle the return value of a number of functions better --- src/saveload/oldloader.cpp | 5 ++--- src/saveload/saveload.cpp | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/saveload') diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp index f6ebb48bc..ff911a899 100644 --- a/src/saveload/oldloader.cpp +++ b/src/saveload/oldloader.cpp @@ -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; } } diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 4bffa40c7..dc63abe5b 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -1848,7 +1848,9 @@ struct FileReader : LoadFilter { /* virtual */ void Reset() { clearerr(this->file); - fseek(this->file, this->begin, SEEK_SET); + if (fseek(this->file, this->begin, SEEK_SET)) { + DEBUG(sl, 1, "Could not reset the file reading"); + } } }; -- cgit v1.2.3-70-g09d2