[Telepathy-commits] [telepathy-glib/master] _make_properties_hash: Don't point property at garbage at the end of the loop
Will Thompson
will.thompson at collabora.co.uk
Wed Sep 17 07:02:28 PDT 2008
Also, add an assertion which should help catch off-by-one errors by the
caller.
---
telepathy-glib/dbus-properties-mixin.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/telepathy-glib/dbus-properties-mixin.c b/telepathy-glib/dbus-properties-mixin.c
index 07c6e79..75eb452 100644
--- a/telepathy-glib/dbus-properties-mixin.c
+++ b/telepathy-glib/dbus-properties-mixin.c
@@ -781,18 +781,34 @@ tp_dbus_properties_mixin_make_properties_hash (
va_list ap;
GHashTable *table;
const gchar *interface, *property;
+ gboolean first = TRUE;
table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) tp_g_value_slice_free);
va_start (ap, first_property);
- for (interface = first_interface, property = first_property;
+ for (interface = first_interface;
interface != NULL;
- interface = va_arg (ap, gchar *), property = va_arg (ap, gchar *))
+ interface = va_arg (ap, gchar *))
{
GValue *value = g_slice_new0 (GValue);
+ if (first)
+ {
+ property = first_property;
+ first = FALSE;
+ }
+ else
+ {
+ property = va_arg (ap, gchar *);
+ }
+
+ /* If property is NULL, the caller might have omitted a comma or
+ * something; in any case, it shouldn't be.
+ */
+ g_assert (property != NULL);
+
tp_dbus_properties_mixin_get (object, interface, property,
value, NULL);
/* Fetching our immutable properties had better not fail... */
--
1.5.6.5
More information about the Telepathy-commits
mailing list