From 801da1dfc1cf8f41be8a9e101c28b335af974f93 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 30 Sep 2008 10:47:06 +0000 Subject: [PATCH] Avoid a g_critical(). Pass a large enough result buffer to 2008-09-30 Tor Lillqvist * glocalfile.c (get_volume_for_path) [Win32]: Avoid a g_critical(). Pass a large enough result buffer to GetVolumePathNameW(). Just use MAX_PATH. svn path=/trunk/; revision=7561 --- gio/ChangeLog | 6 ++++++ gio/glocalfile.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index a1ee3f5..d399947 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,9 @@ +2008-09-30 Tor Lillqvist + + * glocalfile.c (get_volume_for_path) [Win32]: Avoid a + g_critical(). Pass a large enough result buffer to + GetVolumePathNameW(). Just use MAX_PATH. + 2008-09-29 David Zeuthen * gvolume.c: Clarify semantics of g_volume_mount_finish() (#552168) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 3b5f24d..eec7480 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -844,10 +844,10 @@ get_volume_for_path (const char *path) wchar_t *wpath; wchar_t *result; - wpath = g_utf8_to_utf16 (path, -1, NULL, &len, NULL); - result = g_new (wchar_t, len + 2); + wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL); + result = g_new (wchar_t, MAX_PATH); - if (!GetVolumePathNameW (wpath, result, len + 2)) + if (!GetVolumePathNameW (wpath, result, MAX_PATH)) { char *msg = g_win32_error_message (GetLastError ()); g_critical ("GetVolumePathName failed: %s", msg); -- 2.7.4