summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-11-23 13:15:07 +0000
committerrubidium <rubidium@openttd.org>2013-11-23 13:15:07 +0000
commit0e9c9921040a1d0e2aa4b820b20535f40a0d75a3 (patch)
tree6dd17568acbfb75610e9b4e248436426ead79e89 /src/saveload
parentb3e93d65208f74802595b12e682d98a4d534a328 (diff)
downloadopenttd-0e9c9921040a1d0e2aa4b820b20535f40a0d75a3.tar.xz
(svn r26058) -Fix: handle the return value of a number of functions better
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/oldloader.cpp5
-rw-r--r--src/saveload/saveload.cpp4
2 files changed, 5 insertions, 4 deletions
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");
+ }
}
};