summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/misc.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-01-10 14:02:40 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-01-10 14:02:40 +0000
commit5ebc752cd3731e2de4140eff3e6fca0e5d82fcf4 (patch)
tree11f557a57f695cc248b1223b36bab57727028269 /protocols/VKontakte/src/misc.cpp
parent9b73dafa2f6da6bf60f98e17475c624f0497806b (diff)
VKontakte (detect by coverity) :
fix memory leaks on CMString s=json_as_string(...) fix memory leaks on CVkFileUploadParam::GetType() fix missing break in switch on OnChatEvent fix uninitialized field in CVkChatMessage, CVkChatInfo, AsyncHttpRequest, CVkChatUser fix potential crash in OnReciveUpload version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@11817 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r--protocols/VKontakte/src/misc.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 833dbebceb..c80990c01f 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -19,6 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" };
+CMString json_as_CMString(JSONNODE* pNode)
+{
+ ptrT pString(json_as_string(pNode));
+ CMString tszString = pString;
+ return tszString;
+}
+
+
LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField)
{
for (int i = 0; i < pReq->headersCount; i++)
@@ -80,6 +88,9 @@ AsyncHttpRequest::AsyncHttpRequest()
AddHeader("Accept-Encoding", "booo");
pUserInfo = NULL;
m_iRetry = MAX_RETRIES;
+ bNeedsRestart = false;
+ bIsMainConn = false;
+ m_pFunc = NULL;
}
AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
@@ -107,6 +118,8 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
m_pFunc = pFunc;
pUserInfo = NULL;
m_iRetry = MAX_RETRIES;
+ bNeedsRestart = false;
+ bIsMainConn = false;
}
AsyncHttpRequest::~AsyncHttpRequest()
@@ -306,7 +319,8 @@ void CVkProto::OnReceiveSmth(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
JSONROOT pRoot;
JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- debugLog(_T("CVkProto::OnReceiveSmth %s"), json_as_string(pResponse));
+ ptrT ptszLog(json_as_string(pResponse));
+ debugLog(_T("CVkProto::OnReceiveSmth %s"), ptszLog);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -750,7 +764,7 @@ CMString CVkProto::GetVkPhotoItem(JSONNODE *pPhoto, BBCSupport iBBC)
tszRes.AppendFormat(_T("%s (%dx%d)"), SetBBCString(TranslateT("Photo"), iBBC, vkbbcUrl, ptszLink).GetBuffer(), iWidth, iHeight);
if (m_iIMGBBCSupport)
tszRes.AppendFormat(_T("\n\t[img]%s[/img]"), ptszPreviewLink ? ptszPreviewLink : (ptszLink ? ptszLink : _T("")));
- CMString tszText = json_as_string(json_get(pPhoto, "text"));
+ CMString tszText = json_as_CMString(json_get(pPhoto, "text"));
if (!tszText.IsEmpty())
tszRes += "\n" + tszText;
@@ -930,7 +944,7 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments, BBCSupport iBBC)
ptrT ptszUrl(json_as_string(json_get(pLink, "url")));
ptrT ptszTitle(json_as_string(json_get(pLink, "title")));
ptrT ptszDescription(json_as_string(json_get(pLink, "description")));
- CMString tszImage(json_as_string(json_get(pLink, "image_src")));
+ CMString tszImage(json_as_CMString(json_get(pLink, "image_src")));
res.AppendFormat(_T("%s: %s"),
SetBBCString(TranslateT("Link"), iBBC, vkbbcB).GetBuffer(),