summaryrefslogtreecommitdiff
path: root/src/fs/virtfs/fsdir.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-07-17 18:55:36 +0300
committerAndrei Karas <akaras@inbox.ru>2017-07-17 18:55:36 +0300
commit4ecdb004e81a459ea63ebd7127e1c945df43f9ce (patch)
treea8ece58a62724c4b088484e0b5c1f44fdbf2f7e1 /src/fs/virtfs/fsdir.cpp
parent334c1c50dfa57da0b91687e097db295a6a3b699b (diff)
downloadmanaverse-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.tar.gz
manaverse-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.tar.bz2
manaverse-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.tar.xz
manaverse-4ecdb004e81a459ea63ebd7127e1c945df43f9ce.zip
Fix issues detected by coverity.
Diffstat (limited to 'src/fs/virtfs/fsdir.cpp')
-rw-r--r--src/fs/virtfs/fsdir.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
index 60fc9f977..be980ae65 100644
--- a/src/fs/virtfs/fsdir.cpp
+++ b/src/fs/virtfs/fsdir.cpp
@@ -377,6 +377,11 @@ namespace FsDir
}
#ifdef USE_FILE_FOPEN
const long pos = ftell(fd);
+ if (pos < 0)
+ {
+ reportAlways("FsDir::fileLength ftell error.");
+ return -1;
+ }
fseek(fd, 0, SEEK_END);
const long sz = ftell(fd);
fseek(fd, pos, SEEK_SET);
@@ -483,6 +488,13 @@ namespace FsDir
#ifdef USE_FILE_FOPEN
fseek(fd, 0, SEEK_END);
const long sz = ftell(fd);
+ if (sz < 0)
+ {
+ reportAlways("FsDir::fileLength ftell error.");
+ if (fd != FILEHDEFAULT)
+ FILECLOSE(fd);
+ return nullptr;
+ }
fseek(fd, 0, SEEK_SET);
fileSize = static_cast<int>(sz);
#else // USE_FILE_FOPEN