From 6ab3a1af91a51d86d0c85ebbf44dcbdb549e1af5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 6 Feb 2017 22:07:53 +0300 Subject: - fix for a possible memory leak; - enhanced debug info --- protocols/Discord/src/proto.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols/Discord/src') 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; -- cgit v1.2.3