From f94f16702b87c3c876096723f8e6ad94d63847aa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 6 May 2013 16:07:39 +0000 Subject: more mem leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@4593 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_avatars.cpp | 38 ++++++++++++----------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'protocols/Skype/src/skype_avatars.cpp') diff --git a/protocols/Skype/src/skype_avatars.cpp b/protocols/Skype/src/skype_avatars.cpp index 9e53ff1485..27bf4a5dd0 100644 --- a/protocols/Skype/src/skype_avatars.cpp +++ b/protocols/Skype/src/skype_avatars.cpp @@ -62,9 +62,8 @@ wchar_t * CSkypeProto::GetContactAvatarFilePath(HANDLE hContact) if (m_hAvatarsFolder == NULL || FoldersGetCustomPathT(m_hAvatarsFolder, path, MAX_PATH, _T(""))) { - wchar_t *tmpPath = ::Utils_ReplaceVarsT(L"%miranda_avatarcache%"); + mir_ptr tmpPath( ::Utils_ReplaceVarsT(L"%miranda_avatarcache%")); ::mir_sntprintf(path, MAX_PATH, _T("%s\\%S"), tmpPath, this->m_szModuleName); - ::mir_free(tmpPath); } DWORD dwAttributes = GetFileAttributes(path); @@ -97,15 +96,13 @@ INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam) mir_ptr sid = ::db_get_wsa(pai->hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN); if (sid) { - wchar_t *path = this->GetContactAvatarFilePath(pai->hContact); + mir_ptr path( this->GetContactAvatarFilePath(pai->hContact)); if (path && !_waccess(path, 0)) { ::wcsncpy(pai->filename, path, SIZEOF(pai->filename)); pai->format = PA_FORMAT_JPEG; return GAIR_SUCCESS; } - - ::mir_free(path); } return GAIR_NOAVATAR; @@ -159,11 +156,10 @@ INT_PTR __cdecl CSkypeProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (!wParam) return -2; - wchar_t *path = this->GetContactAvatarFilePath(NULL); + mir_ptr path( this->GetContactAvatarFilePath(NULL)); if (path && CSkypeProto::FileExists(path)) { ::wcsncpy((wchar_t *)wParam, path, (int)lParam); - ::mir_free(path); return 0; } @@ -173,57 +169,49 @@ INT_PTR __cdecl CSkypeProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) { wchar_t *path = (wchar_t *)lParam; - int iRet = -1; - if (path) { - wchar_t *avatarPath = this->GetContactAvatarFilePath(NULL); + mir_ptr avatarPath( this->GetContactAvatarFilePath(NULL)); if ( !::wcscmp(path, avatarPath)) { this->Log(L"New avatar path are same with old."); - return iRet; + return -1; } SEBinary avatar = this->GetAvatarBinary(path); if (avatar.size() == 0) { this->Log(L"Failed to read avatar file."); - return iRet; + return -1; } if (this->IsAvatarChanged(avatar)) { this->Log(L"New avatar are same with old."); - return iRet; + return -1; } if ( !::CopyFile(path, avatarPath, FALSE)) { this->Log(L"Failed to copy new avatar to local storage."); - return iRet; + return -1; } Skype::VALIDATERESULT result = Skype::NOT_VALIDATED; if (!this->account->SetAvatar(avatar, result)) { this->Log(CSkypeProto::ValidationReasons[result]); - return iRet; + return -1; } uint newTS = this->account->GetUintProp(Account::P_AVATAR_IMAGE); ::db_set_dw(NULL, this->m_szModuleName, "AvatarTS", newTS); - iRet = 0; - - ::mir_free(avatarPath); - } - else - { - this->account->SetBinProperty(Account::P_AVATAR_IMAGE, SEBinary()); - ::db_unset(NULL, this->m_szModuleName, "AvatarTS"); - iRet = 0; + return 0; } - return iRet; + this->account->SetBinProperty(Account::P_AVATAR_IMAGE, SEBinary()); + ::db_unset(NULL, this->m_szModuleName, "AvatarTS"); + return 0; } SEBinary CSkypeProto::GetAvatarBinary(wchar_t *path) -- cgit v1.2.3