summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_avatars.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-05-06 16:07:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-05-06 16:07:39 +0000
commitf94f16702b87c3c876096723f8e6ad94d63847aa (patch)
treeb0cd74c1351429b4748474557aabfd56c2150323 /protocols/Skype/src/skype_avatars.cpp
parent27d17244cb0af6f8b04e2b6725d504c336dabb07 (diff)
more mem leaks
git-svn-id: http://svn.miranda-ng.org/main/trunk@4593 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src/skype_avatars.cpp')
-rw-r--r--protocols/Skype/src/skype_avatars.cpp38
1 files changed, 13 insertions, 25 deletions
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<wchar_t> 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<wchar_t> sid = ::db_get_wsa(pai->hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
if (sid)
{
- wchar_t *path = this->GetContactAvatarFilePath(pai->hContact);
+ mir_ptr<wchar_t> 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<wchar_t> 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<wchar_t> 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)