[PATCH] Fix symlink resolution (yet again!)



It turns out that _gnome_vfs_uri_resolve_all_symlinks_uri used to unref
an URI before accessing its uri->text. This is bad of course if its
refcount is 1.

Proposed patch attached, which fixes bug 318457 [1].

We could have saved the new_uri unref/ref if we introduced an additional
variable instead of using the (later unrefed) new_uri. However, 3 local
URI variables in this function are definitly confusing enough.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=318457

-- 
Christian Neumair <chris gnome-de org>
Index: libgnomevfs/gnome-vfs-utils.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-utils.c,v
retrieving revision 1.102
diff -u -p -r1.102 gnome-vfs-utils.c
--- libgnomevfs/gnome-vfs-utils.c	15 Sep 2005 11:02:53 -0000	1.102
+++ libgnomevfs/gnome-vfs-utils.c	10 Oct 2005 19:37:24 -0000
@@ -1991,9 +1993,14 @@ _gnome_vfs_uri_resolve_all_symlinks_uri 
 			resolved_uri = gnome_vfs_uri_resolve_relative (new_uri,
 								       info->symlink_name);
 			if (*p != 0) {
+				gnome_vfs_uri_unref (new_uri);
+
+				new_uri = gnome_vfs_uri_append_string (resolved_uri, p);
+
 				gnome_vfs_uri_unref (uri);
-				uri = gnome_vfs_uri_append_string (resolved_uri, p);
 				gnome_vfs_uri_unref (resolved_uri);
+
+				uri = gnome_vfs_uri_ref (new_uri);
 			} else {
 				gnome_vfs_uri_unref (uri);
 				uri = resolved_uri;

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]