diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-03 00:35:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-03 00:35:26 +0300 |
commit | 60cce948bc8419c15a7fe8ab9669f4ae87c5ef76 (patch) | |
tree | c9b7046a93904ba651bcc0c1881eb566fc97e37d /src | |
parent | 80f2a4020254c020df6ba751a3d0e5dc1af0774e (diff) | |
download | manaplus-60cce948bc8419c15a7fe8ab9669f4ae87c5ef76.tar.gz manaplus-60cce948bc8419c15a7fe8ab9669f4ae87c5ef76.tar.bz2 manaplus-60cce948bc8419c15a7fe8ab9669f4ae87c5ef76.tar.xz manaplus-60cce948bc8419c15a7fe8ab9669f4ae87c5ef76.zip |
another fixes from Coverity checks.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/download.cpp | 19 | ||||
-rw-r--r-- | src/utils/translation/poparser.cpp | 11 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp index 32625b181..2124736ca 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -286,7 +286,11 @@ int Download::downloadThread(void *ptr) if (!d->mOptions.memoryWrite) { - fclose(file); + if (file) + { + fclose(file); + file = nullptr; + } ::remove(outFilename.c_str()); } attempts++; @@ -305,7 +309,11 @@ int Download::downloadThread(void *ptr) if (d->mAdler != adler) { - fclose(file); + if (file) + { + fclose(file); + file = nullptr; + } // Remove the corrupted file ::remove(d->mFileName.c_str()); @@ -316,7 +324,11 @@ int Download::downloadThread(void *ptr) continue; // Bail out here to avoid the renaming } } - fclose(file); + if (file) + { + fclose(file); + file = nullptr; + } // Any existing file with this name is deleted first, otherwise // the rename will fail on Windows. @@ -331,6 +343,7 @@ int Download::downloadThread(void *ptr) if (file) { fclose(file); + file = nullptr; complete = true; } } diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index dc201d4b3..2c880ba27 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -46,8 +46,15 @@ void PoParser::openFile(std::string name) int size; char *buf = static_cast<char*>(resman->loadFile(getFileName(name), size)); - mFile.str(std::string(buf, size)); - free(buf); + if (buf) + { + mFile.str(std::string(buf, size)); + free(buf); + } + else + { + mFile.clear(); + } } PoDict *PoParser::load(const std::string &lang, const std::string &fileName, |