summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_transfer.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-04-16 18:32:24 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-04-16 18:32:24 +0000
commit37edb76041ddaf7a500add3e49108a3106db43a8 (patch)
tree9850ad6aa3c0f73c00d8dac987899b36c6e693e6 /protocols/Tox/src/tox_transfer.cpp
parent5c365012d42bd08fce526394372d396caa6ea04c (diff)
Tox:
- Fixed memory leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@12869 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_transfer.cpp')
-rw-r--r--protocols/Tox/src/tox_transfer.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp
index cb2e3d7e0f..777671f418 100644
--- a/protocols/Tox/src/tox_transfer.cpp
+++ b/protocols/Tox/src/tox_transfer.cpp
@@ -138,11 +138,11 @@ void CToxProto::OnFileReceiveData(Tox*, uint32_t friendNumber, uint32_t fileNumb
FileTransferParam *transfer = proto->transfers.Get(friendNumber, fileNumber);
if (transfer == NULL)
{
- tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
+// tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
return;
}
- if (length == 0 || (length == 0 && position == UINT64_MAX))
+ if (length == 0 || (position == UINT64_MAX))
{
//receiving is finished
proto->debugLogA(__FUNCTION__": finised the transfer of file (%d)", fileNumber);
@@ -186,12 +186,6 @@ HANDLE CToxProto::OnSendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHAR **pp
if (friendNumber == UINT32_MAX)
return NULL;
- TCHAR *fileName = _tcsrchr(ppszFiles[0], '\\') + 1;
-
- size_t fileDirLength = fileName - ppszFiles[0];
- TCHAR *fileDir = (TCHAR*)mir_alloc(sizeof(TCHAR)*(fileDirLength + 1));
- _tcsncpy(fileDir, ppszFiles[0], fileDirLength);
- fileDir[fileDirLength] = '\0';
FILE *hFile = _tfopen(ppszFiles[0], _T("rb"));
if (hFile == NULL)
@@ -200,6 +194,12 @@ HANDLE CToxProto::OnSendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHAR **pp
return NULL;
}
+ TCHAR *fileName = _tcsrchr(ppszFiles[0], '\\') + 1;
+ size_t fileDirLength = fileName - ppszFiles[0];
+ TCHAR *fileDir = (TCHAR*)mir_alloc(sizeof(TCHAR)*(fileDirLength + 1));
+ _tcsncpy(fileDir, ppszFiles[0], fileDirLength);
+ fileDir[fileDirLength] = '\0';
+
_fseeki64(hFile, 0, SEEK_END);
uint64_t fileSize = _ftelli64(hFile);
rewind(hFile);
@@ -210,6 +210,8 @@ HANDLE CToxProto::OnSendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHAR **pp
if (sendError != TOX_ERR_FILE_SEND_OK)
{
debugLogA(__FUNCTION__": failed to send file (%d)", sendError);
+ mir_free(fileDir);
+ mir_free(name);
return NULL;
}
@@ -218,7 +220,8 @@ HANDLE CToxProto::OnSendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHAR **pp
transfer->pfts.tszWorkingDir = fileDir;
transfer->hFile = hFile;
transfers.Add(transfer);
-
+
+ mir_free(name);
return (HANDLE)transfer;
}
@@ -229,7 +232,7 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber,
FileTransferParam *transfer = proto->transfers.Get(friendNumber, fileNumber);
if (transfer == NULL)
{
- tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
+// tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
return;
}
@@ -259,6 +262,7 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber,
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
transfer->status = FAILED;
tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
+ mir_free(data);
return;
}