aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2010-11-22 20:43:22 +0000
committerGerald Combs <gerald@wireshark.org>2010-11-22 20:43:22 +0000
commit68974e890a0a641c6f58e1d463ce41280c70a836 (patch)
tree874ba2a7dc7e36a158623c3012fe95653325bad0 /wsutil
parent8bc65842e03d81f750e8e27ab10850845abdb8c0 (diff)
Make sure we pass a directory path and not a file path to
SetCurrentDirectory. Should fix bug 5420. svn path=/trunk/; revision=35010
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/file_util.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/wsutil/file_util.c b/wsutil/file_util.c
index 2695d98170..f901c99b8b 100644
--- a/wsutil/file_util.c
+++ b/wsutil/file_util.c
@@ -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)