From 02e1bc294a44555846184114ad45f98e730447bd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 28 Mar 2011 17:15:27 +0100 Subject: [PATCH 04/25] marshal_basic: if marshalling a string fails, critical and return FALSE This could be OOM, but it could also be non-UTF-8. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30171 --- dbus/dbus-gvalue.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index 379038f..5922dd2 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -1444,15 +1444,25 @@ marshal_basic (DBusMessageIter *iter, const GValue *value) } return TRUE; case G_TYPE_STRING: - /* FIXME, the GValue string may not be valid UTF-8 */ { const char *v = g_value_get_string (value); if (!v) v = ""; + + /* FIXME: fd.o #16320: consider using g_return_if_fail to check UTF-8 + * validity */ + if (!dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &v)) - goto nomem; + { + gchar *s = g_strdup_value_contents (value); + + g_critical ("Unable to marshal string (not UTF-8 or OOM?): %s", + s); + g_free (s); + return FALSE; + } } return TRUE; @@ -1462,10 +1472,6 @@ marshal_basic (DBusMessageIter *iter, const GValue *value) return FALSE; } } - - nomem: - g_error ("no memory"); - return FALSE; } static gboolean -- 1.7.4.1