summaryrefslogtreecommitdiff
path: root/src/net/download.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-11 14:48:19 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-11 15:24:57 +0300
commitf1b82c1b06604c2c1eed750a6c980aa0b5355560 (patch)
tree3e524583691af0e5a17e5ee974439b4c6ea07ef4 /src/net/download.cpp
parent452f2489bf3225235797ea08ea0d466f80409a87 (diff)
downloadmv-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.gz
mv-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.bz2
mv-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.xz
mv-f1b82c1b06604c2c1eed750a6c980aa0b5355560.zip
First part of checks from Parasoft C++ Test.
Diffstat (limited to 'src/net/download.cpp')
-rw-r--r--src/net/download.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 9dd90a1d1..fad1ec0b4 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -69,7 +69,8 @@ Download::Download(void *const ptr, const std::string &url,
mError(static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1))),
mIgnoreError(ignoreError)
{
- mError[0] = 0;
+ if (mError)
+ mError[0] = 0;
mOptions.cancel = 0;
mOptions.memoryWrite = 0;
@@ -117,6 +118,8 @@ unsigned long Download::fadler32(FILE *const file)
// Calculate Adler-32 checksum
char *const buffer = static_cast<char*>(malloc(fileSize));
+ if (!buffer)
+ return 0;
const uInt read = static_cast<uInt>(fread(buffer, 1, fileSize, file));
unsigned long adler = adler32(0L, Z_NULL, 0);
adler = adler32(static_cast<uInt>(adler),
@@ -174,7 +177,8 @@ bool Download::start()
if (!mThread)
{
logger->log1(DOWNLOAD_ERROR_MESSAGE_THREAD);
- strcpy(mError, DOWNLOAD_ERROR_MESSAGE_THREAD);
+ if (mError)
+ strcpy(mError, DOWNLOAD_ERROR_MESSAGE_THREAD);
mUpdateFunction(mPtr, DOWNLOAD_STATUS_THREAD_ERROR, 0, 0);
if (!mIgnoreError)
return false;
@@ -290,9 +294,14 @@ int Download::downloadThread(void *ptr)
break;
case CURLE_COULDNT_CONNECT:
default:
- logger->log("curl error %d: %s host: %s",
- res, d->mError, d->mUrl.c_str());
+ {
+ if (d->mError)
+ {
+ logger->log("curl error %d: %s host: %s",
+ res, d->mError, d->mUrl.c_str());
+ }
break;
+ }
}
if (d->mOptions.cancel)