From a8deb4ad5586a2b6a90957a610ad64c8e10e95f1 Mon Sep 17 00:00:00 2001
From: Tobias Weimer <wishmaster51@googlemail.com>
Date: Sat, 6 Jun 2015 21:13:00 +0000
Subject: XFire: - fix for a typo in r12294 (thx White-Tiger) - fixed memory
 leaks - minor other fixes

git-svn-id: http://svn.miranda-ng.org/main/trunk@14032 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 protocols/Xfire/src/Xfire_voicechat.cpp |  5 ++---
 protocols/Xfire/src/iniupdater.cpp      |  6 +++---
 protocols/Xfire/src/main.cpp            |  1 -
 protocols/Xfire/src/options.cpp         |  6 ------
 protocols/Xfire/src/tools.cpp           | 26 +++++++++++++-------------
 protocols/Xfire/src/variables.cpp       |  3 ---
 6 files changed, 18 insertions(+), 29 deletions(-)

(limited to 'protocols')

diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp
index dfb5f89a0a..543d75de6a 100644
--- a/protocols/Xfire/src/Xfire_voicechat.cpp
+++ b/protocols/Xfire/src/Xfire_voicechat.cpp
@@ -329,12 +329,11 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) {
 	}
 
 	DWORD size = 0;
-	MIB_TCPTABLE_OWNER_PID* ptab = NULL;
 	//tcptabelle holen
 	GetExtendedTcpTable(NULL, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0);
 	//�berhaupt was drin?
 	if (size) {
-		ptab = (MIB_TCPTABLE_OWNER_PID*)malloc(size);
+		MIB_TCPTABLE_OWNER_PID *ptab = (MIB_TCPTABLE_OWNER_PID*)malloc(size);
 		//liste auslesen
 		if (GetExtendedTcpTable(ptab, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0) == NO_ERROR)
 		{
@@ -355,7 +354,7 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) {
 					packet->gameid = XFIREVOICECHAT_MUMBLE;
 					this->currentvoice = XFIREVOICECHAT_MUMBLE;
 					//table wieder freigeben
-					delete ptab;
+					free(ptab);
 					//mumble l�uft + ip gefunden also TRUE
 					return TRUE;
 				}
diff --git a/protocols/Xfire/src/iniupdater.cpp b/protocols/Xfire/src/iniupdater.cpp
index bbd63279b8..072e0f692e 100644
--- a/protocols/Xfire/src/iniupdater.cpp
+++ b/protocols/Xfire/src/iniupdater.cpp
@@ -89,9 +89,9 @@ void UpdateMyIcons(LPVOID dummy) {
 
 	//ini pfad rausbekommen
 	char file[1024], file2[1024], file3[1024];
-	mir_snprintf(file,SIZEOF(file), "%sxfire_games.new",inipath);
-	mir_snprintf(file2,SIZEOF(file2), "%sxfire_games.ini",inipath);
-	mir_snprintf(file3,SIZEOF(file3), "%sxfire_games.old",inipath);
+	mir_snprintf(file,SIZEOF(file), "%sicons.new",inipath);
+	mir_snprintf(file2,SIZEOF(file2), "%sicons.dll",inipath);
+	mir_snprintf(file3,SIZEOF(file3), "%sicons.old",inipath);
 
 	mir_snprintf(request, SIZEOF(request), "%s%d", ICO_URLREQUEST, getfilesize(file2));
 
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp
index 15907ac515..a292edfa43 100644
--- a/protocols/Xfire/src/main.cpp
+++ b/protocols/Xfire/src/main.cpp
@@ -296,7 +296,6 @@ XFireClient::XFireClient(string username_, string password_, char protover, int
 	client = new Client();
 	client->setGameResolver(new DummyXFireGameResolver());
 	client->protocolVersion = protover;
-	avatarloader = new Xfire_avatar_loader(client);
 	this->useproxy = useproxy;
 	this->proxyip = proxyip;
 	this->proxyport = proxyport;
diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp
index 4ac8fd4cd4..58043f1aaa 100644
--- a/protocols/Xfire/src/options.cpp
+++ b/protocols/Xfire/src/options.cpp
@@ -517,7 +517,6 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
 		{
 		case PSN_APPLY:
 		{
-			int reconnectRequired = 0;
 			int ccc;
 
 			hwndTree = GetDlgItem(hwndDlg, IDC_TREE);
@@ -548,11 +547,6 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
 			ccc = SendDlgItemMessage(hwndDlg, IDC_SCANUPDATECB, CB_GETCURSEL, 0, 0);
 			db_set_b(NULL, protocolname, "scanalways", (BYTE)ccc);
 
-			//protocolversion wird autoamtisch vergeben
-			//GetDlgItemTextA(hwndDlg,IDC_PVER,str,SIZEOF(str));
-			//db_set_b(NULL,protocolname,"protover",(char)atoi(str));
-
-			if (reconnectRequired) MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the XFire network before they take effect"), TranslateT("XFire Options"), MB_OK | MB_ICONINFORMATION);
 			return TRUE;
 		}
 
diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp
index ad982108b6..e499fab901 100644
--- a/protocols/Xfire/src/tools.cpp
+++ b/protocols/Xfire/src/tools.cpp
@@ -766,8 +766,9 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain
 	char * buffer2;
 	PPEB peb = NULL;
 	PPROCESS_PARAMETERS proc_params = NULL;
-	PVOID UserPool = (PVOID)LocalAlloc(LPTR, 8192);
+	HLOCAL UserPool = LocalAlloc(LPTR, 8192);
 	PROCESS_BASIC_INFORMATION ProcessInfo;
+	HMODULE hNt = GetModuleHandle(_T("ntdll.dll"));
 
 	//strings leer abbruch
 	if (!mustcontain&&!mustnotcontain)
@@ -776,17 +777,19 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain
 	//pr�fe und lade n�tige funktionen
 	if (_ZwQueryInformationProcess == NULL)
 	{
-		_ZwQueryInformationProcess = (pZwQueryInformationProcess)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwQueryInformationProcess");
+		_ZwQueryInformationProcess = (pZwQueryInformationProcess)GetProcAddress(hNt, "ZwQueryInformationProcess");
 		if (_ZwQueryInformationProcess == NULL)
 		{
+			LocalFree(UserPool);
 			return TRUE;
 		}
 	}
 	if (_ZwReadVirtualMemory == NULL)
 	{
-		_ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwReadVirtualMemory");
+		_ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(hNt, "ZwReadVirtualMemory");
 		if (_ZwReadVirtualMemory == NULL)
 		{
+			LocalFree(UserPool);
 			return TRUE;
 		}
 	}
@@ -839,24 +842,21 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain
 	//lowercase mustcontain/mustnotcontain
 	if (mustcontain)
 		for (unsigned int i = 0; i < mir_strlen(mustcontain); i++)
-		{
-		mustcontain[i] = tolower(mustcontain[i]);
-		}
+			mustcontain[i] = tolower(mustcontain[i]);
+
 	if (mustnotcontain)
 		for (unsigned int i = 0; i < mir_strlen(mustnotcontain); i++)
-		{
-		mustnotcontain[i] = tolower(mustnotcontain[i]);
-		}
+			mustnotcontain[i] = tolower(mustnotcontain[i]);
 
 	string cmdline = buffer2;
 
 	if (mustcontain)
 		if (cmdline.find(mustcontain) != string::npos)
 		{
-		delete[] buffer;
-		delete[] buffer2;
-		LocalFree(UserPool);
-		return TRUE;
+			delete[] buffer;
+			delete[] buffer2;
+			LocalFree(UserPool);
+			return TRUE;
 		}
 		else
 		{
diff --git a/protocols/Xfire/src/variables.cpp b/protocols/Xfire/src/variables.cpp
index 70f167e933..86b5138bc9 100644
--- a/protocols/Xfire/src/variables.cpp
+++ b/protocols/Xfire/src/variables.cpp
@@ -140,9 +140,6 @@ char* Varxfirevoiceip(ARGUMENTSINFO *ai) {
 		ai->flags = AIF_FALSE;
 		return mir_strdup("");
 	}
-
-	ai->flags = AIF_FALSE;
-	return mir_strdup("");
 }
 
 char* Varmyxfirevoice(ARGUMENTSINFO *ai)
-- 
cgit v1.2.3