GNOME Bugzilla – Bug 528600
g_dummy_file_get_parent("scheme://example.com/")
Last modified: 2008-06-11 17:51:54 UTC
g_file_get_parent() is supposed to return: * Returns: a #GFile structure to the parent of the given * #GFile or %NULL if there is no parent. Which implies you can walk up to the root by checking for NULL (and gnome-panel does this) But g_dummy_file_get_parent("scheme://example.com/") Returns the same thing, which puts gnome-panel into a nice infinite loop.
Created attachment 109496 [details] [review] fix it Here's the fix for this; oddly enough we were doing the right thing in GDaemonFile but not in GDummyFile (I guess all of us were using GVFS during testing). It looks to be correct against RFC 3986 if I understand it correctly. Anyways, here's the test case, which I would have included in the patch, but I'm not sure exactly where GIO tests will go and how they should be tooled to run (wrt make check, etc). /** run test via: GIO_USE_VFS=local ./test-528600 **/ #include <glib.h> #include <gio/gio.h> void test_dummy_file_get_parent (void) { GFile *file, *parent_file; file = g_file_new_for_uri ("scheme://example.com"); g_assert_cmpstr (G_OBJECT_TYPE_NAME(file), ==, "GDummyFile"); parent_file = g_file_get_parent (file); g_assert (parent_file == NULL); g_object_unref(file); } int main (int argc, char *argv[]) { g_type_init(); g_test_init(&argc, &argv, NULL); g_test_add_func ("/gio/g_dummy_file_get_parent", test_dummy_file_get_parent); return g_test_run(); }
Created attachment 110003 [details] [review] Christian Neumair's fix Here's Christian Neumair's fix from the other bug. I'm not sure which is better other than that his is simpler (though I'm sadly not familiar enough with that section of code to assure that we're never reaching a state where the path can be NULL). Either way, can we get a GLib maintainer to comment/commit one of these fixes?
*** Bug 530086 has been marked as a duplicate of this bug. ***
Raising severity, we really need to get a fix in for this as it's starting to pop up during usage (albeit strange cases).
I think using g_strcmp0 () instead of plain strcmp () in Christian's patch would be the safest option to solve this.
Bug 528600 – g_dummy_file_get_parent("scheme://example.com/") * gdummyfile.c (g_dummy_file_get_parent): Return NULL if there is no parent. (Owen Taylor, patch by Christian Persch)
s/Persch/Neumair/ ;)