diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-16 18:52:29 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-16 18:52:29 +0000 |
commit | 3c00a78191f46c10f036c789a9ef358f0e049d61 (patch) | |
tree | 96741c418983d401ebba418b579793c8c4959d30 /protocols | |
parent | ab46b98479555c7106087f7d62b6c89f320ca311 (diff) |
Tox:
- attempt to fix numerous crashes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15366 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Tox/src/tox_avatars.cpp | 6 | ||||
-rw-r--r-- | protocols/Tox/src/tox_chatrooms.cpp | 22 | ||||
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 1 | ||||
-rw-r--r-- | protocols/Tox/src/tox_network.cpp | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 13 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.h | 2 |
8 files changed, 22 insertions, 36 deletions
diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index 47c50d3fc2..efa04e6861 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -10,8 +10,10 @@ TCHAR* CToxProto::GetAvatarFilePath(MCONTACT hContact) CreateDirectoryTreeT(path);
ptrT address(getTStringA(hContact, TOX_SETTINGS_ID));
- if (address == NULL)
+ if (address == NULL) {
+ mir_free(path);
return mir_tstrdup(_T(""));
+ }
if (hContact && mir_tstrlen(address) > TOX_PUBLIC_KEY_SIZE * 2)
address[TOX_PUBLIC_KEY_SIZE * 2] = 0;
@@ -30,7 +32,7 @@ void CToxProto::SetToxAvatar(const TCHAR* path) }
fseek(hFile, 0, SEEK_END);
- size_t length = ftell(hFile);
+ long length = ftell(hFile);
rewind(hFile);
if (length > TOX_MAX_AVATAR_SIZE)
{
diff --git a/protocols/Tox/src/tox_chatrooms.cpp b/protocols/Tox/src/tox_chatrooms.cpp index 0ae894be98..08195104c0 100644 --- a/protocols/Tox/src/tox_chatrooms.cpp +++ b/protocols/Tox/src/tox_chatrooms.cpp @@ -80,36 +80,22 @@ int CToxProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) {
return 1;
}
- else if (mir_strcmp(gch->pDest->pszModule, this->m_szModuleName) != 0)
- {
+ else
return 0;
- }
- return 0;
}
-int CToxProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
+int CToxProto::OnGroupChatMenuHook(WPARAM, LPARAM)
{
- GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
- if (mir_strcmpi(gcmi->pszModule, this->m_szModuleName) != 0)
- {
- return 0;
- }
return 0;
}
-INT_PTR CToxProto::OnJoinChatRoom(WPARAM hContact, LPARAM)
+INT_PTR CToxProto::OnJoinChatRoom(WPARAM, LPARAM)
{
- if (hContact)
- {
- }
return 0;
}
-INT_PTR CToxProto::OnLeaveChatRoom(WPARAM hContact, LPARAM)
+INT_PTR CToxProto::OnLeaveChatRoom(WPARAM, LPARAM)
{
- if (hContact)
- {
- }
return 0;
}
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 05ad622089..bee4f7a126 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -350,6 +350,7 @@ void CToxProto::OnConnectionStatusChanged(Tox*, uint32_t friendNumber, TOX_CONNE if (error != TOX_ERR_FILE_SEND_OK)
{
proto->logger->Log(__FUNCTION__": failed to set new avatar");
+ fclose(hFile);
return;
}
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index ea090920c5..9520672494 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -7,7 +7,7 @@ bool CToxProto::IsOnline() void CToxProto::BootstrapNode(const char *address, int port, const char *hexKey)
{
- if (hexKey == NULL)
+ if (hexKey == NULL || toxThread == NULL)
return;
ToxBinAddress binKey(hexKey, TOX_PUBLIC_KEY_SIZE * 2);
TOX_ERR_BOOTSTRAP error;
@@ -101,14 +101,14 @@ void CToxProto::TryConnect() else if (m_iStatus++ > TOX_MAX_CONNECT_RETRIES)
{
SetStatus(ID_STATUS_OFFLINE);
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_NONETWORK);
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
logger->Log(__FUNCTION__": failed to connect to DHT");
}
}
void CToxProto::CheckConnection(int &retriesCount)
{
- if (!toxThread->isConnected)
+ if (!toxThread || !toxThread->isConnected)
{
TryConnect();
}
@@ -151,7 +151,7 @@ void CToxProto::PollingThread(void*) if (!InitToxCore())
{
SetStatus(ID_STATUS_OFFLINE);
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_WRONGPASSWORD);
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
logger->Log(__FUNCTION__": leaving");
return;
}
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 796cdf6606..d103736466 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -21,9 +21,6 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) logger->Log(__FUNCTION__": loading tox profile");
mir_cslock locker(profileLock);
-
- size_t size = 0;
- uint8_t *data = NULL;
ptrT profilePath(GetToxProfilePath());
if (!IsFileExists(profilePath))
@@ -38,16 +35,16 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) }
fseek(profile, 0, SEEK_END);
- size = ftell(profile);
+ long size = ftell(profile);
rewind(profile);
if (size < 0)
{
fclose(profile);
- size = 0;
+ return false;
}
- data = (uint8_t*)mir_calloc(size);
- if (fread((char*)data, sizeof(char), size, profile) != size)
+ uint8_t *data = (uint8_t*)mir_calloc(size);
+ if (fread((char*)data, sizeof(char), size, profile) != (size_t)size)
{
fclose(profile);
ShowNotification(TranslateT("Unable to read Tox profile"), MB_ICONERROR);
@@ -57,7 +54,7 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) }
fclose(profile);
- if (data && tox_is_data_encrypted(data))
+ if (tox_is_data_encrypted(data))
{
pass_ptrA password(mir_utf8encodeW(pass_ptrT(getTStringA("Password"))));
if (password == NULL || mir_strlen(password) == 0)
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 33da319fc4..9937562adb 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -2,7 +2,7 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName)
: PROTO<CToxProto>(protoName, userName),
- hPollingThread(NULL), hOutDevice(NULL)
+ hPollingThread(NULL), hOutDevice(NULL), toxThread(NULL)
{
InitNetlib();
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 04c9a8849f..d67a2df97f 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -78,7 +78,7 @@ private: // tox profile
TCHAR* GetToxProfilePath();
- static TCHAR* CToxProto::GetToxProfilePath(const TCHAR *accountName);
+ static TCHAR* GetToxProfilePath(const TCHAR *accountName);
bool LoadToxProfile(Tox_Options *options);
void SaveToxProfile();
@@ -129,7 +129,7 @@ private: int OnInitStatusMenu();
//services
- INT_PTR __cdecl CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl SetMyNickname(WPARAM wParam, LPARAM lParam);
// options
int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam);
diff --git a/protocols/Tox/src/tox_transfer.h b/protocols/Tox/src/tox_transfer.h index f683b9e046..a8dcc55b62 100644 --- a/protocols/Tox/src/tox_transfer.h +++ b/protocols/Tox/src/tox_transfer.h @@ -47,7 +47,7 @@ struct FileTransferParam uint8_t GetDirection() const
{
- return pfts.flags & PFTS_SENDING ? 0 : 1;
+ return (pfts.flags & PFTS_SENDING) ? 0 : 1;
}
~FileTransferParam()
|