summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-18 20:03:20 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-18 20:03:20 +0000
commit032c5363fbcfe55fc4d32174fcd7ccec40c8bbe8 (patch)
treef8eba47cb1bf7b46912d212e0bf84b432f134469 /plugins
parent9ebf291e927660eac233f0d882c086cfbfa51a63 (diff)
Dropbox: fixed bugs from coverity
git-svn-id: http://svn.miranda-ng.org/main/trunk@13684 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp29
-rw-r--r--plugins/Dropbox/src/file_transfer.h5
2 files changed, 26 insertions, 8 deletions
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp
index ed4b02b6f9..cceb9ea985 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -135,7 +135,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
//
size_t offset = 0;
- char *uploadId = new char[32];
+ char uploadId[32];
int chunkSize = DROPBOX_FILE_CHUNK_SIZE / 4;
if (fileSize < 1024 * 1024)
@@ -143,6 +143,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
else if (fileSize > 20 * 1024 * 1024)
chunkSize = DROPBOX_FILE_CHUNK_SIZE;
+ char *data = (char*)mir_alloc(chunkSize);
while (!feof(hFile) && fileSize != offset)
{
if (ferror(hFile))
@@ -151,20 +152,28 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
if (ftp->isTerminated)
throw TransferException("Transfer was terminated");
- char *data = (char*)mir_alloc(chunkSize);
int count = (int)fread(data, sizeof(char), chunkSize, hFile);
- if (offset == 0)
- instance->SendFileChunkedFirst(data, count, uploadId, offset);
- else
- instance->SendFileChunkedNext(data, count, uploadId, offset);
+ try
+ {
+ if (offset == 0)
+ instance->SendFileChunkedFirst(data, count, uploadId, offset);
+ else
+ instance->SendFileChunkedNext(data, count, uploadId, offset);
+ }
+ catch (TransferException)
+ {
+ mir_free(data);
+ fclose(hFile);
+ throw;
+ }
ftp->pfts.currentFileProgress += count;
ftp->pfts.totalProgress += count;
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ftp->hProcess, (LPARAM)&ftp->pfts);
}
-
+ mir_free(data);
fclose(hFile);
ptrA utf8_fileName(mir_utf8encodeW(fileName));
@@ -230,7 +239,11 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
dbei.pBlob = (PBYTE)message;
db_event_add(ftp->hContact, &dbei);
}
- else CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)ftp->hContact, (LPARAM)data);
+ else
+ {
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)ftp->hContact, (LPARAM)data);
+ mir_free(message);
+ }
}
else
{
diff --git a/plugins/Dropbox/src/file_transfer.h b/plugins/Dropbox/src/file_transfer.h
index f27ab76695..1a86ec7588 100644
--- a/plugins/Dropbox/src/file_transfer.h
+++ b/plugins/Dropbox/src/file_transfer.h
@@ -37,13 +37,18 @@ struct FileTransferParam
ptszFolders = NULL;
relativePathStart = 0;
+ hProcess = NULL;
+ hContact = NULL;
+
isTerminated = false;
pfts.cbSize = sizeof(this->pfts);
pfts.flags = PFTS_TCHAR | PFTS_SENDING;
+ pfts.hContact = NULL;
pfts.currentFileNumber = 0;
pfts.currentFileProgress = 0;
pfts.currentFileSize = 0;
+ pfts.currentFileTime = 0;
pfts.totalBytes = 0;
pfts.totalFiles = 0;
pfts.totalProgress = 0;