diff options
author | rubidium <rubidium@openttd.org> | 2013-11-23 13:17:45 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-11-23 13:17:45 +0000 |
commit | 78a316d349f02c76b89c6fd7597e7013c062133a (patch) | |
tree | f9ed8c8d687f7081d6de04c70a82060d4ed2f040 /src/fileio.cpp | |
parent | 29ef70c246293ebde72f36e0a01483eeac6f7fdf (diff) | |
download | openttd-78a316d349f02c76b89c6fd7597e7013c062133a.tar.xz |
(svn r26061) -Fix: negative result of ftell wasn't handled correctly in some cases
Diffstat (limited to 'src/fileio.cpp')
-rw-r--r-- | src/fileio.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp index e17eaf654..851090c07 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -254,7 +254,8 @@ void FioOpenFile(int slot, const char *filename, Subdirectory subdir) #endif /* LIMITED_FDS */ f = FioFOpenFile(filename, "rb", subdir); if (f == NULL) usererror("Cannot open file '%s'", filename); - uint32 pos = ftell(f); + long pos = ftell(f); + if (pos < 0) usererror("Cannot read file '%s'", filename); FioCloseFile(slot); // if file was opened before, close it _fio.handles[slot] = f; @@ -271,7 +272,7 @@ void FioOpenFile(int slot, const char *filename, Subdirectory subdir) _fio.usage_count[slot] = 0; _fio.open_handles++; #endif /* LIMITED_FDS */ - FioSeekToFile(slot, pos); + FioSeekToFile(slot, (uint32)pos); } static const char * const _subdirs[] = { |