From f1b82c1b06604c2c1eed750a6c980aa0b5355560 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 11 Oct 2013 14:48:19 +0300 Subject: First part of checks from Parasoft C++ Test. --- src/net/download.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/net/download.cpp') 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(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(malloc(fileSize)); + if (!buffer) + return 0; const uInt read = static_cast(fread(buffer, 1, fileSize, file)); unsigned long adler = adler32(0L, Z_NULL, 0); adler = adler32(static_cast(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) -- cgit v1.2.3-60-g2f50