Do not crash if append NULL string to IBusMessage.
authorPeng Huang <shawn.p.huang@gmail.com>
Tue, 13 Oct 2009 06:11:46 +0000 (14:11 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Tue, 13 Oct 2009 06:11:46 +0000 (14:11 +0800)
src/ibusenginedesc.c
src/ibusmessage.c

index d5b4326146f42a88ace8eeb67d226604e3bf2f4a..08f0622ab1adc300f4d9d65d687412f6151b948a 100644 (file)
@@ -289,9 +289,7 @@ ibus_engine_desc_parse_xml_node (IBusEngineDesc *desc,
 
 #define PARSE_ENTRY(field_name, element_name)                   \
         if (g_strcmp0 (sub_node->name, element_name) == 0) {    \
-            if (desc->field_name != NULL) {                     \
-                g_free (desc->field_name);                      \
-            }                                                   \
+            g_free (desc->field_name);                          \
             desc->field_name = g_strdup (sub_node->text);       \
             continue;                                           \
         }
index efc05885da7ce386150dddbafae31bfc337afb3b..9be3f649781c75082ef2ff41939ac8cee4cb0e73 100644 (file)
@@ -525,7 +525,7 @@ ibus_message_iter_append (IBusMessageIter *iter,
     case G_TYPE_STRING:
         {
             const gchar *v;
-            v = * (gchar **)value;
+            v = *(gchar **)value != NULL ? * (gchar **)value : "";
             return dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &v);
         }
     case G_TYPE_INT64: