Fix crash in registry
authorPeng Huang <shawn.p.huang@gmail.com>
Tue, 20 Apr 2010 09:21:41 +0000 (17:21 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Tue, 20 Apr 2010 09:21:41 +0000 (17:21 +0800)
bus/registry.c
src/ibuscomponent.c

index 58c056f..1878ef2 100644 (file)
@@ -347,7 +347,10 @@ bus_registry_load_in_dir (BusRegistry *registry,
 
         path = g_build_filename (dirname, filename, NULL);
         component = ibus_component_new_from_file (path);
-        registry->components = g_list_append (registry->components, component);
+        if (component != NULL) {
+            g_object_ref_sink (component);
+            registry->components = g_list_append (registry->components, component);
+        }
 
         g_free (path);
     }
index ad0c356..c541f7a 100644 (file)
@@ -335,7 +335,9 @@ ibus_component_output (IBusComponent *component,
 
 #define OUTPUT_ENTRY(field, element)                                        \
     {                                                                       \
-        gchar *escape_text = g_markup_escape_text (component->field, -1);   \
+        gchar *escape_text =                                                \
+            g_markup_escape_text (component->field ?                        \
+                                    component->field : "", -1);             \
         g_string_append_indent (output, indent + 1);                        \
         g_string_append_printf (output, "<"element">%s</"element">\n",      \
                                 escape_text);                               \