diff options
author | George Hazan <ghazan@miranda.im> | 2017-02-06 22:07:53 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-02-06 22:07:53 +0300 |
commit | 6ab3a1af91a51d86d0c85ebbf44dcbdb549e1af5 (patch) | |
tree | 99acfb6157cdfd803d9e25537d748db6e73d223a /protocols | |
parent | 672548110a740feaeccf83a91f340f59738419a6 (diff) |
- fix for a possible memory leak;
- enhanced debug info
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/proto.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 52af24578d..991327a38d 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -464,6 +464,7 @@ void CDiscordProto::SendFileThread(void *param) FILE *in = _wfopen(p->wszFileName, L"rb"); if (in == NULL) { + debugLogA("cannot open file %S for reading", p->wszFileName.c_str()); LBL_Error: ProtoBroadcastAck(p->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, param); delete p; @@ -516,8 +517,11 @@ void CDiscordProto::SendFileThread(void *param) memcpy(pReq->pData, szBody.c_str(), szBody.GetLength()); size_t cbRead = fread(pReq->pData + szBody.GetLength(), 1, cbBytes, in); fclose(in); - if (cbBytes != cbRead) + if (cbBytes != cbRead) { + debugLogA("cannot read file %S: %d bytes read instead of %d", p->wszFileName.c_str(), cbRead, cbBytes); + delete pReq; goto LBL_Error; + } memcpy(pReq->pData + szBody.GetLength() + cbBytes, szBoundary, szBoundary.GetLength()); pReq->pUserInfo = p; |