Plug some mem leaks

g_variant_get (v, "s", &str) returns a string copy; use "&s" instead.

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
Christian Persch 2010-05-13 19:20:26 +02:00 committed by David Zeuthen
parent 60e7ae26af
commit 4ad4c306c3
6 changed files with 27 additions and 29 deletions

View File

@ -167,7 +167,7 @@ print_methods (GDBusConnection *c,
g_variant_unref (result);
goto out;
}
g_variant_get (result, "(s)", &xml_data);
g_variant_get (result, "(&s)", &xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);
@ -229,7 +229,9 @@ print_paths (GDBusConnection *c,
g_variant_unref (result);
goto out;
}
g_variant_get (result, "(s)", &xml_data);
g_variant_get (result, "(&s)", &xml_data);
//g_printerr ("xml=`%s'", xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);
@ -241,8 +243,6 @@ print_paths (GDBusConnection *c,
goto out;
}
//g_printerr ("xml=`%s'", xml_data);
//g_printerr ("bar `%s'\n", path);
if (node->interfaces != NULL)
@ -308,7 +308,7 @@ print_names (GDBusConnection *c,
}
g_variant_get (result, "(as)", &iter);
while (g_variant_iter_loop (iter, "s", &str))
g_hash_table_insert (name_set, g_strdup (str), NULL);
g_hash_table_insert (name_set, str, NULL);
g_variant_iter_free (iter);
g_variant_unref (result);
@ -337,7 +337,7 @@ print_names (GDBusConnection *c,
}
g_variant_get (result, "(as)", &iter);
while (g_variant_iter_loop (iter, "s", &str))
g_hash_table_insert (name_set, g_strdup (str), NULL);
g_hash_table_insert (name_set, str, NULL);
g_variant_iter_free (iter);
g_variant_unref (result);
@ -476,7 +476,7 @@ call_helper_get_method_in_signature (GDBusConnection *c,
goto out;
}
g_variant_get (result, "(s)", &xml_data);
g_variant_get (result, "(&s)", &xml_data);
node_info = g_dbus_node_info_new_for_xml (xml_data, error);
if (node_info == NULL)
goto out;
@ -1071,14 +1071,14 @@ dump_interface (GDBusConnection *c,
&iter);
while ((item = g_variant_iter_next_value (iter)))
{
const gchar *key;
gchar *key;
GVariant *value;
g_variant_get (item,
"{sv}",
&key,
&value);
g_hash_table_insert (properties, g_strdup (key), g_variant_ref (value));
g_hash_table_insert (properties, key, g_variant_ref (value));
}
}
g_variant_unref (result);
@ -1354,7 +1354,7 @@ handle_introspect (gint *argc,
g_variant_get_type_string (result));
goto out;
}
g_variant_get (result, "(s)", &xml_data);
g_variant_get (result, "(&s)", &xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);

View File

@ -1839,7 +1839,6 @@ initable_init (GInitable *initable,
if (connection->priv->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION)
{
GVariant *hello_result;
const gchar *s;
hello_result = g_dbus_connection_call_sync (connection,
"org.freedesktop.DBus", /* name */
@ -1854,8 +1853,7 @@ initable_init (GInitable *initable,
if (hello_result == NULL)
goto out;
g_variant_get (hello_result, "(s)", &s);
connection->priv->bus_unique_name = g_strdup (s);
g_variant_get (hello_result, "(s)", &connection->priv->bus_unique_name);
g_variant_unref (hello_result);
//g_debug ("unique name is `%s'", connection->priv->bus_unique_name);
}
@ -3217,12 +3215,12 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
if (is_get)
g_variant_get (g_dbus_message_get_body (message),
"(ss)",
"(&s&s)",
&interface_name,
&property_name);
else
g_variant_get (g_dbus_message_get_body (message),
"(ssv)",
"(&s&sv)",
&interface_name,
&property_name,
NULL);
@ -3321,12 +3319,12 @@ handle_getset_property (GDBusConnection *connection,
if (is_get)
g_variant_get (g_dbus_message_get_body (message),
"(ss)",
"(&s&s)",
&interface_name,
&property_name);
else
g_variant_get (g_dbus_message_get_body (message),
"(ssv)",
"(&s&sv)",
&interface_name,
&property_name,
NULL);
@ -3456,7 +3454,7 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection *connec
handled = FALSE;
g_variant_get (g_dbus_message_get_body (message),
"(s)",
"(&s)",
&interface_name);
if (vtable == NULL || vtable->get_property == NULL)
@ -3498,7 +3496,7 @@ handle_get_all_properties (GDBusConnection *connection,
handled = FALSE;
g_variant_get (g_dbus_message_get_body (message),
"(s)",
"(&s)",
&interface_name);
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if there is
@ -4651,11 +4649,11 @@ handle_subtree_method_invocation (GDBusConnection *connection,
else if (is_property_get || is_property_set || is_property_get_all)
{
if (is_property_get)
g_variant_get (g_dbus_message_get_body (message), "(ss)", &interface_name, NULL);
g_variant_get (g_dbus_message_get_body (message), "(&s&s)", &interface_name, NULL);
else if (is_property_set)
g_variant_get (g_dbus_message_get_body (message), "(ssv)", &interface_name, NULL, NULL);
g_variant_get (g_dbus_message_get_body (message), "(&s&sv)", &interface_name, NULL, NULL);
else if (is_property_get_all)
g_variant_get (g_dbus_message_get_body (message), "(s)", &interface_name, NULL, NULL);
g_variant_get (g_dbus_message_get_body (message), "(&s)", &interface_name, NULL, NULL);
else
g_assert_not_reached ();

View File

@ -2247,7 +2247,7 @@ g_dbus_message_to_gerror (GDBusMessage *message,
if (body != NULL && g_variant_is_of_type (body, G_VARIANT_TYPE ("(s)")))
{
const gchar *error_message;
g_variant_get (body, "(s)", &error_message);
g_variant_get (body, "(&s)", &error_message);
g_dbus_error_set_dbus_error (error,
error_name,
error_message,

View File

@ -261,7 +261,7 @@ on_name_lost_or_acquired (GDBusConnection *connection,
if (g_strcmp0 (signal_name, "NameLost") == 0)
{
g_variant_get (parameters, "(s)", &name);
g_variant_get (parameters, "(&s)", &name);
if (g_strcmp0 (name, client->name) == 0)
{
call_lost_handler (client);
@ -269,7 +269,7 @@ on_name_lost_or_acquired (GDBusConnection *connection,
}
else if (g_strcmp0 (signal_name, "NameAcquired") == 0)
{
g_variant_get (parameters, "(s)", &name);
g_variant_get (parameters, "(&s)", &name);
if (g_strcmp0 (name, client->name) == 0)
{
call_acquired_handler (client);

View File

@ -289,7 +289,7 @@ on_name_owner_changed (GDBusConnection *connection,
goto out;
g_variant_get (parameters,
"(sss)",
"(&s&s&s)",
&name,
&old_owner,
&new_owner);
@ -336,7 +336,7 @@ get_name_owner_cb (GObject *source_object,
NULL);
if (result != NULL)
{
g_variant_get (result, "(s)", &name_owner);
g_variant_get (result, "(&s)", &name_owner);
}
if (name_owner != NULL)

View File

@ -848,7 +848,7 @@ process_get_all_reply (GDBusProxy *proxy,
g_variant_iter_init (&iter, g_variant_get_child_value (result, 0));
while ((item = g_variant_iter_next_value (&iter)) != NULL)
{
const gchar *key;
gchar *key;
GVariant *value;
g_variant_get (item,
@ -858,7 +858,7 @@ process_get_all_reply (GDBusProxy *proxy,
//g_print ("got %s -> %s\n", key, g_variant_markup_print (value, FALSE, 0, 0));
g_hash_table_insert (proxy->priv->properties,
g_strdup (key),
key,
value); /* steals value */
}
out: