summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_files.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/vk_files.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/vk_files.cpp')
-rw-r--r--protocols/VKontakte/src/vk_files.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 05115bfaa6..79e5edc400 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -50,7 +50,8 @@ CVkFileUploadParam::VKFileType CVkFileUploadParam::GetType()
_tsplitpath(FileName, DRIVE, DIR, FNAME, EXT);
CMStringA fn;
- fn.AppendFormat("%s%s", mir_utf8encodeT(FNAME), mir_utf8encodeT(EXT));
+ ptrA pszFNAME(mir_utf8encodeT(FNAME)), pszEXT(mir_utf8encodeT(EXT));
+ fn.AppendFormat("%s%s", pszFNAME, pszEXT);
fname = mir_strdup(fn.GetBuffer());
if (tlstrstr(img, EXT)) {
@@ -173,7 +174,7 @@ void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
return;
}
- CMStringA uri = json_as_string(json_get(pResponse, "upload_url"));
+ CMStringA uri = json_as_CMString(json_get(pResponse, "upload_url"));
if (uri.IsEmpty()) {
SendFileFiled(fup);
return;
@@ -253,17 +254,18 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
JSONROOT pRoot;
CheckJsonResponse(pReq, reply, pRoot);
- CMString server = json_as_string(json_get(pRoot, "server"));
- CMString hash = json_as_string(json_get(pRoot, "hash"));
+ ptrT server(json_as_string(json_get(pRoot, "server")));
+ ptrT hash(json_as_string(json_get(pRoot, "hash")));
CMString upload;
AsyncHttpRequest *pUploadReq;
switch (fup->GetType()) {
case CVkFileUploadParam::typeImg:
- upload = json_as_string(json_get(pRoot, "photo"));
+ upload = json_as_CMString(json_get(pRoot, "photo"));
if (upload == _T("[]")) {
SendFileFiled(fup, _T("NotUpload Photo"));
+ return;
}
pUploadReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.saveMessagesPhoto.json", true, &CVkProto::OnReciveUploadFile)
<< TCHAR_PARAM("server", server)
@@ -272,7 +274,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
<< VER_API;
break;
case CVkFileUploadParam::typeAudio:
- upload = json_as_string(json_get(pRoot, "audio"));
+ upload = json_as_CMString(json_get(pRoot, "audio"));
if (upload == _T("[]")) {
SendFileFiled(fup, _T("NotUpload Audio"));
return;
@@ -284,7 +286,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
<< VER_API;
break;
case CVkFileUploadParam::typeDoc:
- upload = json_as_string(json_get(pRoot, "file"));
+ upload = json_as_CMString(json_get(pRoot, "file"));
if (upload.IsEmpty()) {
SendFileFiled(fup, _T("NotUpload Doc"));
return;