[Bug 75204] [next] remove TpAsv from public API
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed Feb 19 16:58:45 CET 2014
https://bugs.freedesktop.org/show_bug.cgi?id=75204
--- Comment #2 from Simon McVittie <simon.mcvittie at collabora.co.uk> ---
First 4 look good.
-static GHashTable *
-create_request (void)
+static GVariantDict
+dict_request (void)
{
- return tp_asv_new (
- TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT,
- TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT,
- TP_ENTITY_TYPE_CONTACT,
- TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, "alice",
- NULL);
+ GVariantDict dict;
+
+ g_variant_dict_init (&dict, NULL);
+
+ g_variant_dict_insert (&dict,
+ TP_PROP_CHANNEL_CHANNEL_TYPE, "s", TP_IFACE_CHANNEL_TYPE_TEXT);
+ g_variant_dict_insert (&dict,
+ TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, "u", TP_ENTITY_TYPE_CONTACT);
+ g_variant_dict_insert (&dict,
+ TP_PROP_CHANNEL_TARGET_ID, "s", "alice");
+
+ return dict;
}
This is undefined behaviour. You're returning a pointer to stack contents which
are no longer guaranteed not to be scribbled on after this function returns.
Please do something like this:
/* @dict is uninitialized on entry. */
static void
init_dict_request (GVariantDict *dict)
{
g_variant_dict_init (dict, NULL);
...
}
caller
{
GVariantDict dict;
init_dict_request (&dict);
}
or this:
/* @dict must already be initialized on entry. */
static void
fill_dict_request (GVariantDict *dict)
{
}
caller
{
GVariantDict dict;
g_variant_dict_init (&dict, NULL);
fill_dict_request (&dict);
}
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the telepathy-bugs
mailing list