Make sure we pass a directory path and not a file path to
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 22 Nov 2010 20:43:22 +0000 (20:43 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 22 Nov 2010 20:43:22 +0000 (20:43 +0000)
SetCurrentDirectory.  Should fix bug 5420.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35010 f5534014-38df-0310-8fa8-9805f1628bb7

wsutil/file_util.c

index 2695d98170f74845b757ff0eb0111d1f463751bf..f901c99b8be2498fcc0ca5c75269bd5fddb68532 100644 (file)
@@ -447,26 +447,30 @@ ws_stdio_freopen (const gchar *filename,
 /* DLL loading */
 static gboolean
 init_dll_load_paths() {
-      TCHAR path_pfx[MAX_PATH];
+      TCHAR path_w[MAX_PATH];
 
       if (program_path && system_path)
            return TRUE;
 
       /* XXX - Duplicate code in filesystem.c:init_progfile_dir */
-      if (GetModuleFileName(NULL, path_pfx, MAX_PATH) == 0 || GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+      if (GetModuleFileName(NULL, path_w, MAX_PATH) == 0 || GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
            return FALSE;
       }
 
       if (!program_path) {
-           program_path = g_utf16_to_utf8(path_pfx, -1, NULL, NULL, NULL);
+           gchar *app_path;
+           app_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL);
+           /* We could use PathRemoveFileSpec here but we'd have to link to Shlwapi.dll */
+           program_path = g_path_get_dirname(app_path);
+           g_free(app_path);
       }
 
-      if (GetSystemDirectory(path_pfx, MAX_PATH) == 0) {
+      if (GetSystemDirectory(path_w, MAX_PATH) == 0) {
            return FALSE;
       }
 
       if (!system_path) {
-           system_path = g_utf16_to_utf8(path_pfx, -1, NULL, NULL, NULL);
+           system_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL);
       }
 
       if (program_path && system_path)