Comment 1 for bug 433673

Revision history for this message
A. Walton (awalton) wrote :

To be honest, the whole NautilusQuery code needs a rewrite. It's entirely inadequate and sub-par (e.g. the usage of g_file_test() before opening the file is a race, g_file_get_contents() is sync. i/o, etc). Could do a couple of band-aid patches to prevent it from crashing, but this is probably a fairly rare crash:

diff --git a/libnautilus-private/nautilus-query.c b/libnautilus-private/nautilus
index 267620d..b6a3f55 100644
--- a/libnautilus-private/nautilus-query.c
+++ b/libnautilus-private/nautilus-query.c
@@ -300,15 +300,18 @@ nautilus_query_load (char *file)
        NautilusQuery *query;
        char *xml;
        gsize xml_len;
-
+
+ xml_len = 0;
+ query = NULL;
+
        if (!g_file_test (file, G_FILE_TEST_EXISTS)) {
                return NULL;
        }
-

- g_file_get_contents (file, &xml, &xml_len, NULL);
- query = nautilus_query_parse_xml (xml, xml_len);
+ if (g_file_get_contents (file, &xml, &xml_len, NULL) && xml_len != 0) {
+ query = nautilus_query_parse_xml (xml, xml_len);
+ }

(then we have to make sure that the code's doing the right thing with the NULL return, etc)