Bug 573843 – g_get_current_dir returns non-absolute path
authorAlexander Larsson <alexl@redhat.com>
Wed, 4 Mar 2009 13:47:53 +0000 (13:47 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Wed, 4 Mar 2009 13:47:53 +0000 (13:47 +0000)
2009-03-04  Alexander Larsson  <alexl@redhat.com>

Bug 573843 – g_get_current_dir returns non-absolute path

* glocalfile.c (canonicalize_filename):
Handle the case where g_get_current_dir() returns a non-absolute path.

svn path=/trunk/; revision=7958

gio/ChangeLog
gio/glocalfile.c

index 6df6bc295129debe6ee1c9aa992cd19821e71107..1417f65dd12d3696d4f4ac2093868cb1fe81dbee 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-04  Alexander Larsson  <alexl@redhat.com>
+
+       Bug 573843 – g_get_current_dir returns non-absolute path
+
+       * glocalfile.c (canonicalize_filename):
+       Handle the case where g_get_current_dir() returns a non-absolute path.
+
 2009-03-04  Alexander Larsson  <alexl@redhat.com>
 
        Bug 573970 – crash in gunixvolumemonitor:update_mounts when unmounting
index 217ee988cc01bed20154b983050b46cb6da3df39..b1d7353df70bf23030974c67a44c1485e1594e44 100644 (file)
@@ -244,6 +244,15 @@ canonicalize_filename (const char *filename)
 
   start = (char *)g_path_skip_root (canon);
 
+  if (start == NULL)
+    {
+      /* This shouldn't really happen, as g_get_current_dir() should
+        return an absolute pathname, but bug 573843 shows this is
+        not always happening */
+      g_free (canon);
+      return g_build_filename (G_DIR_SEPARATOR_S, filename, NULL);
+    }
+  
   /* POSIX allows double slashes at the start to
    * mean something special (as does windows too).
    * So, "//" != "/", but more than two slashes