summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-01-06 17:20:24 +0200
committerGeorge Hazan <ghazan@miranda.im>2019-01-06 17:20:24 +0200
commit80ccccc6c8889ef287e78e0cf31a268ec2a39942 (patch)
tree620b6849e0ff2bd9ebf13aee551c0c1c944051a1 /protocols
parentac34a82d07d24856aee5629fec42ce9d0f33800d (diff)
ICQ: crash fix
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Icq10/src/server.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp
index 835b0aac16..d67b2924a5 100644
--- a/protocols/Icq10/src/server.cpp
+++ b/protocols/Icq10/src/server.cpp
@@ -516,26 +516,32 @@ void CIcqProto::OnStartSession(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
void CIcqProto::OnReceiveAvatar(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
{
MCONTACT hContact = (MCONTACT)pReq->pUserInfo;
+ PROTO_AVATAR_INFORMATION ai = {};
+ ai.hContact = hContact;
+
+ if (pReply->resultCode != 200 || pReply->pData == nullptr) {
+LBL_Error:
+ ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, HANDLE(&ai), 0);
+ return;
+ }
const wchar_t *pwszExtension;
- PROTO_AVATAR_INFORMATION ai;
- ai.hContact = hContact;
ai.format = ProtoGetBufferFormat(pReply->pData, &pwszExtension);
setByte(hContact, "AvatarType", ai.format);
GetAvatarFileName(hContact, ai.filename, _countof(ai.filename));
FILE *out = _wfopen(ai.filename, L"wb");
- if (out != nullptr) {
- fwrite(pReply->pData, pReply->dataLength, 1, out);
- fclose(out);
-
- if (hContact != 0) {
- ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, HANDLE(&ai), 0);
- debugLogW(L"Broadcast new avatar: %s", ai.filename);
- }
- else CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0);
+ if (out == nullptr)
+ goto LBL_Error;
+
+ fwrite(pReply->pData, pReply->dataLength, 1, out);
+ fclose(out);
+
+ if (hContact != 0) {
+ ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, HANDLE(&ai), 0);
+ debugLogW(L"Broadcast new avatar: %s", ai.filename);
}
- else ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, HANDLE(&ai), 0);
+ else CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0);
}
void CIcqProto::OnSearchResults(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)