summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_history.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-09-07 15:30:02 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-09-07 15:30:02 +0000
commitc76cb483df20f8058deedcf5500b20ea5af98cf6 (patch)
treef8037ae70e781efbde6d56864c7cb9b9f508e15c /protocols/VKontakte/src/vk_history.cpp
parent19dbdd9ae7fd04bde5d5761bce97344842d2a6d9 (diff)
VKontakte:
code refactoring fix memory leaks and corruption fix for support MessageState version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@15294 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_history.cpp')
-rw-r--r--protocols/VKontakte/src/vk_history.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index b0fd49772b..1e6e1736ad 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -169,15 +169,20 @@ void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveHistoryMessages %d", reply->resultCode);
- if (reply->resultCode != 200)
+ if (reply->resultCode != 200 || !pReq->pUserInfo)
return;
JSONNode jnRoot;
+ CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo;
const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
- if (!jnResponse)
+ if (!jnResponse) {
+ if (!pReq->bNeedsRestart || m_bTerminated) {
+ delete param;
+ pReq->pUserInfo = NULL;
+ }
return;
-
- CVkSendMsgParam *param = (CVkSendMsgParam*)pReq->pUserInfo;
+ }
+
int iTime = jnResponse["datetime"].as_int();
const JSONNode &jnMsgs = jnResponse["items"];
const JSONNode &jnFUsers = jnResponse["fwd_users"];
@@ -249,5 +254,8 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
if (count == iRCount && once == 0)
GetServerHistory(param->hContact, param->iCount + count, iRCount, iTime, param->iMsgID);
- delete param;
+ if (!pReq->bNeedsRestart || m_bTerminated) {
+ delete param;
+ pReq->pUserInfo = NULL;
+ }
} \ No newline at end of file