diff pidgin/win32/winpidgin.c @ 30900:3d045343e04d

Use some fully qualified dll locations. There wasn't anything wrong with this as far as I can tell, but since we know specifically where what we're looking for is, this is probably better. Also, plug a small leak and try to find our enchant dll instead of any other one that is in the PATH.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 31 Aug 2010 01:49:53 +0000
parents 140990e07e01
children 2c29fe4757a2
line wrap: on
line diff
--- a/pidgin/win32/winpidgin.c	Tue Aug 31 01:23:28 2010 +0000
+++ b/pidgin/win32/winpidgin.c	Tue Aug 31 01:49:53 2010 +0000
@@ -605,9 +605,9 @@
 		char *lpszCmdLine, int nCmdShow) {
 	wchar_t errbuf[512];
 	wchar_t pidgin_dir[MAX_PATH];
+	wchar_t *pidgin_dir_start = NULL;
 	wchar_t exe_name[MAX_PATH];
 	HMODULE hmod;
-	wchar_t *tmp;
 	wchar_t *wtmp;
 	int pidgin_argc;
 	char **pidgin_argv; /* This is in utf-8 */
@@ -672,14 +672,14 @@
 	if (GetModuleFileNameW(NULL, pidgin_dir, MAX_PATH) != 0) {
 
 		/* primitive dirname() */
-		tmp = wcsrchr(pidgin_dir, L'\\');
+		pidgin_dir_start = wcsrchr(pidgin_dir, L'\\');
 
-		if (tmp) {
+		if (pidgin_dir_start) {
 			HMODULE hmod;
-			tmp[0] = L'\0';
+			pidgin_dir_start[0] = L'\0';
 
 			/* tmp++ will now point to the executable file name */
-			wcscpy(exe_name, tmp + 1);
+			wcscpy(exe_name, pidgin_dir_start + 1);
 
 			wcscat(pidgin_dir, L"\\exchndl.dll");
 			if ((hmod = LoadLibraryW(pidgin_dir))) {
@@ -702,7 +702,8 @@
 				proc = GetProcAddress(hmod, "SetDebugInfoDir");
 				if (proc) {
 					char *pidgin_dir_ansi = NULL;
-					tmp[0] = L'\0';
+					/* Restore pidgin_dir to point to where the executable is */
+					pidgin_dir_start[0] = L'\0';
 					i = WideCharToMultiByte(CP_ACP, 0, pidgin_dir,
 						-1, NULL, 0, NULL, NULL);
 					if (i != 0) {
@@ -728,7 +729,8 @@
 
 			}
 
-			tmp[0] = L'\0';
+			/* Restore pidgin_dir to point to where the executable is */
+			pidgin_dir_start[0] = L'\0';
 		}
 	} else {
 		DWORD dw = GetLastError();
@@ -763,9 +765,14 @@
 			return 0;
 
 	/* Now we are ready for Pidgin .. */
-	if ((hmod = LoadLibraryW(L"pidgin.dll")))
+	wcscat(pidgin_dir, L"\\pidgin.dll");
+	if ((hmod = LoadLibraryW(pidgin_dir)))
 		pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
 
+	/* Restore pidgin_dir to point to where the executable is */
+	if (pidgin_dir_start)
+		pidgin_dir_start[0] = L'\0';
+
 	if (!pidgin_main) {
 		DWORD dw = GetLastError();
 		BOOL mod_not_found = (dw == ERROR_MOD_NOT_FOUND || dw == ERROR_DLL_NOT_FOUND);