From 374784a1370ad0c375126227134367c7775bb515 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sun, 17 Apr 2016 09:00:30 +0000 Subject: SkypeWeb: memleaks fix git-svn-id: http://svn.miranda-ng.org/main/trunk@16680 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/http_request.h | 8 ++++---- protocols/SkypeWeb/src/requests/asm/files.h | 6 +++--- protocols/SkypeWeb/src/requests/avatars.h | 2 +- protocols/SkypeWeb/src/requests/login.h | 16 ++++++---------- protocols/SkypeWeb/src/requests/search.h | 1 - protocols/SkypeWeb/src/skype_login.cpp | 4 ++-- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/protocols/SkypeWeb/src/http_request.h b/protocols/SkypeWeb/src/http_request.h index 816c5b3807..b9aa13d7dc 100644 --- a/protocols/SkypeWeb/src/http_request.h +++ b/protocols/SkypeWeb/src/http_request.h @@ -53,7 +53,7 @@ struct FORMAT_VALUE : public VALUE { va_list args; va_start(args, _valueFormat); - szValue.AppendFormatV(_valueFormat, args); + szValue.FormatV(_valueFormat, args); va_end(args); } }; @@ -253,7 +253,7 @@ public: pData = NULL; } - ~HttpRequest() + virtual ~HttpRequest() { for (int i = 0; i < headersCount; i++) { @@ -263,7 +263,7 @@ public: mir_free(headers); } - NETLIBHTTPREQUEST * Send(HANDLE hConnection) + NETLIBHTTPREQUEST* Send(HANDLE hConnection) { if (url.Find("://") == -1) url.Insert(0, ((flags & NLHRF_SSL) ? "https://" : "http://")); @@ -278,7 +278,7 @@ public: mir_snprintf(message, "Send request to %s", szUrl); CallService(MS_NETLIB_LOG, (WPARAM)hConnection, (LPARAM)&message); - return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)this); + return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)(NETLIBHTTPREQUEST*)this); } }; diff --git a/protocols/SkypeWeb/src/requests/asm/files.h b/protocols/SkypeWeb/src/requests/asm/files.h index f9846c23b3..f16052150d 100644 --- a/protocols/SkypeWeb/src/requests/asm/files.h +++ b/protocols/SkypeWeb/src/requests/asm/files.h @@ -8,7 +8,7 @@ public: { flags &= (~NLHRF_DUMPASTEXT); Headers - << CHAR_VALUE("Authorization", CMStringA(::FORMAT, "skype_token %s", li.api.szToken)) + << FORMAT_VALUE("Authorization", "skype_token %s", li.api.szToken) << CHAR_VALUE("Content-Type", "text/json"); JSONNode node, jPermissions, jPermission(JSON_ARRAY); @@ -30,7 +30,7 @@ public: HttpRequest(REQUEST_PUT, FORMAT, "api.asm.skype.com/v1/objects/%s/content/original", szObject) { Headers - << CHAR_VALUE("Authorization", CMStringA(::FORMAT, "skype_token %s", li.api.szToken)) + << FORMAT_VALUE("Authorization", "skype_token %s", li.api.szToken) << CHAR_VALUE("Content-Type", "application/octet-stream"); pData = (char*)mir_alloc(size); @@ -40,7 +40,7 @@ public: } ~ASMObjectUploadRequest() { - mir_free(pData); HttpRequest::~HttpRequest(); + mir_free(pData); } }; \ No newline at end of file diff --git a/protocols/SkypeWeb/src/requests/avatars.h b/protocols/SkypeWeb/src/requests/avatars.h index e2cb9659e2..3c12b5d0b1 100644 --- a/protocols/SkypeWeb/src/requests/avatars.h +++ b/protocols/SkypeWeb/src/requests/avatars.h @@ -44,8 +44,8 @@ public: ~SetAvatarRequest() { - mir_free(pData); HttpRequest::~HttpRequest(); + mir_free(pData); } }; diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h index 045e852bc2..7314f58d2e 100644 --- a/protocols/SkypeWeb/src/requests/login.h +++ b/protocols/SkypeWeb/src/requests/login.h @@ -21,24 +21,20 @@ along with this program. If not, see . class LoginOAuthRequest : public HttpRequest { public: - LoginOAuthRequest(const char *username, const char *password) : + LoginOAuthRequest(CMStringA username, const char *password) : HttpRequest(REQUEST_POST, "api.skype.com/login/skypetoken") { - CMStringA user(username); user.MakeLower(); - - pass_ptrA str(CMStringA(::FORMAT, "%s\nskyper\n%s", user, password).Detach()); + username.MakeLower(); + CMStringA hashStr(::FORMAT, "%s\nskyper\n%s", username, password); BYTE digest[16]; - - mir_md5_hash((BYTE*)((char*)str), mir_strlen(str), digest); - - pass_ptrA hash(mir_base64_encode(digest, sizeof(digest))); + mir_md5_hash((const BYTE*)hashStr.GetString(), hashStr.GetLength(), digest); Body << CHAR_VALUE("scopes", "client") << CHAR_VALUE("clientVersion", ptrA(mir_urlEncode("0/7.4.85.102/259/"))) - << CHAR_VALUE("username", ptrA(mir_urlEncode(user))) - << CHAR_VALUE("passwordHash", pass_ptrA(mir_urlEncode(hash))); + << CHAR_VALUE("username", ptrA(mir_urlEncode(username))) + << CHAR_VALUE("passwordHash", pass_ptrA(mir_urlEncode(ptrA(mir_base64_encode(digest, sizeof(digest)))))); } }; diff --git a/protocols/SkypeWeb/src/requests/search.h b/protocols/SkypeWeb/src/requests/search.h index 4be8e2ef69..7549006e58 100644 --- a/protocols/SkypeWeb/src/requests/search.h +++ b/protocols/SkypeWeb/src/requests/search.h @@ -28,7 +28,6 @@ public: << CHAR_VALUE("keyWord", string); Headers << CHAR_VALUE("Accept", "application/json") - << CHAR_VALUE("Connection", "keep-alive") << CHAR_VALUE("X-Skypetoken", li.api.szToken); } }; diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp index 5ffe9c610c..594d83409b 100644 --- a/protocols/SkypeWeb/src/skype_login.cpp +++ b/protocols/SkypeWeb/src/skype_login.cpp @@ -42,7 +42,7 @@ void CSkypeProto::Login() if (strchr(li.szSkypename, '@')) SendRequest(new LoginMSRequest(), &CSkypeProto::OnMSLoginFirst); else - SendRequest(new LoginOAuthRequest(li.szSkypename, szPassword), &CSkypeProto::OnLoginOAuth); + SendRequest(new LoginOAuthRequest((char*)li.szSkypename, szPassword), &CSkypeProto::OnLoginOAuth); } } @@ -192,7 +192,7 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response) if (response->resultCode == 401) { delSetting("TokenExpiresIn"); - SendRequest(new LoginOAuthRequest(li.szSkypename, ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))), &CSkypeProto::OnLoginOAuth); + SendRequest(new LoginOAuthRequest((char*)li.szSkypename, pass_ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))), &CSkypeProto::OnLoginOAuth); return; } else if (response->resultCode == 400) -- cgit v1.2.3