From 5ebc752cd3731e2de4140eff3e6fca0e5d82fcf4 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Sat, 10 Jan 2015 14:02:40 +0000 Subject: 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 --- protocols/VKontakte/src/misc.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'protocols/VKontakte/src/misc.cpp') 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 . 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(), -- cgit v1.2.3