diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-07-17 18:55:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-07-17 18:55:36 +0300 |
commit | 4ecdb004e81a459ea63ebd7127e1c945df43f9ce (patch) | |
tree | a8ece58a62724c4b088484e0b5c1f44fdbf2f7e1 /src/fs/virtfs/fsdirrwops.cpp | |
parent | 334c1c50dfa57da0b91687e097db295a6a3b699b (diff) | |
download | manaplus-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.tar.gz manaplus-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.tar.bz2 manaplus-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.tar.xz manaplus-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.zip |
Fix issues detected by coverity.
Diffstat (limited to 'src/fs/virtfs/fsdirrwops.cpp')
-rw-r--r-- | src/fs/virtfs/fsdirrwops.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fs/virtfs/fsdirrwops.cpp b/src/fs/virtfs/fsdirrwops.cpp index bef2534fb..b428ed333 100644 --- a/src/fs/virtfs/fsdirrwops.cpp +++ b/src/fs/virtfs/fsdirrwops.cpp @@ -25,6 +25,7 @@ #include "fs/virtfs/file.h" #include "utils/cast.h" +#include "utils/checkutils.h" PRAGMA48(GCC diagnostic push) PRAGMA48(GCC diagnostic ignored "-Wshadow") @@ -86,6 +87,11 @@ namespace FsDir int64_t len = 0; #ifdef USE_FILE_FOPEN const long curpos = ftell(fd); + if (curpos < 0) + { + reportAlways("FsDir::fileLength ftell error."); + return -1; + } fseek(fd, 0, SEEK_END); len = ftell(fd); // fseek(fd, curpos, SEEK_SET); @@ -105,7 +111,10 @@ namespace FsDir if (len == -1) { #ifdef USE_FILE_FOPEN - fseek(fd, curpos, SEEK_SET); + if (fseek(fd, curpos, SEEK_SET) < 0) + { + reportAlways("FsDir::fileLength fseek error."); + } #endif // USE_FILE_FOPEN logger->assertLog( "VirtFs::rwops_seek:Can't find end of file."); |