summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-04-05 16:25:15 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-08-17 19:19:20 +0100
commit9e97f9744e7ffeb04a105087da6143931195ce77 (patch)
treea12437db94a85257c1e0c4eb841266cb427a5550
parentbfd1c05174b86c9dfcf1b22a4fa0b2c552dfc902 (diff)
get_all_object_properties: if _dbus_gvalue_marshal fails, bail out
This isn't necessarily OOM: _dbus_gvalue_marshal can fail due to programming errors. If so, raise a critical warning, then (if that wasn't fatal) return a D-Bus error to be sent to the caller. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=35766 Reviewed-by: Cosimo Alfarano <cosimo.alfarano@collabora.co.uk>
-rw-r--r--dbus/dbus-gobject.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
index da3d7b0..1a82c42 100644
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -1347,8 +1347,32 @@ get_all_object_properties (DBusConnection *connection,
&iter_dict_value))
goto oom;
+ g_free (variant_sig);
+
+ /* this can fail via programming error: the GObject property was
+ * malformed (non-UTF8 string or something) */
if (!_dbus_gvalue_marshal (&iter_dict_value, &value))
- goto oom;
+ {
+ gchar *contents = g_strdup_value_contents (&value);
+ gchar *error_message = g_strdup_printf (
+ "cannot GetAll(%s): failed to serialize %s value of type %s: %s",
+ wincaps_propiface, prop_name, G_VALUE_TYPE_NAME (&value),
+ contents);
+
+ g_critical ("%s", error_message);
+
+ /* abandon ship! */
+ dbus_message_iter_abandon_container (&iter_dict_entry,
+ &iter_dict_value);
+ dbus_message_iter_abandon_container (&iter_dict, &iter_dict_entry);
+ dbus_message_unref (ret);
+ ret = error_or_die (message, DBUS_ERROR_FAILED, error_message);
+
+ g_free (contents);
+ g_free (error_message);
+ g_value_unset (&value);
+ return ret;
+ }
/* these shouldn't fail except by OOM now that we were successful */
if (!dbus_message_iter_close_container (&iter_dict_entry,
@@ -1358,7 +1382,6 @@ get_all_object_properties (DBusConnection *connection,
goto oom;
g_value_unset (&value);
- g_free (variant_sig);
}
if (!dbus_message_iter_close_container (&iter_ret, &iter_dict))