Commit 4ad4c306 authored by Christian Persch's avatar Christian Persch Committed by David Zeuthen

Plug some mem leaks

g_variant_get (v, "s", &str) returns a string copy; use "&s" instead.
Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
parent 60e7ae26
...@@ -167,7 +167,7 @@ print_methods (GDBusConnection *c, ...@@ -167,7 +167,7 @@ print_methods (GDBusConnection *c,
g_variant_unref (result); g_variant_unref (result);
goto out; goto out;
} }
g_variant_get (result, "(s)", &xml_data); g_variant_get (result, "(&s)", &xml_data);
error = NULL; error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error); node = g_dbus_node_info_new_for_xml (xml_data, &error);
...@@ -229,7 +229,9 @@ print_paths (GDBusConnection *c, ...@@ -229,7 +229,9 @@ print_paths (GDBusConnection *c,
g_variant_unref (result); g_variant_unref (result);
goto out; goto out;
} }
g_variant_get (result, "(s)", &xml_data); g_variant_get (result, "(&s)", &xml_data);
//g_printerr ("xml=`%s'", xml_data);
error = NULL; error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error); node = g_dbus_node_info_new_for_xml (xml_data, &error);
...@@ -241,8 +243,6 @@ print_paths (GDBusConnection *c, ...@@ -241,8 +243,6 @@ print_paths (GDBusConnection *c,
goto out; goto out;
} }
//g_printerr ("xml=`%s'", xml_data);
//g_printerr ("bar `%s'\n", path); //g_printerr ("bar `%s'\n", path);
if (node->interfaces != NULL) if (node->interfaces != NULL)
...@@ -308,7 +308,7 @@ print_names (GDBusConnection *c, ...@@ -308,7 +308,7 @@ print_names (GDBusConnection *c,
} }
g_variant_get (result, "(as)", &iter); g_variant_get (result, "(as)", &iter);
while (g_variant_iter_loop (iter, "s", &str)) 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_iter_free (iter);
g_variant_unref (result); g_variant_unref (result);
...@@ -337,7 +337,7 @@ print_names (GDBusConnection *c, ...@@ -337,7 +337,7 @@ print_names (GDBusConnection *c,
} }
g_variant_get (result, "(as)", &iter); g_variant_get (result, "(as)", &iter);
while (g_variant_iter_loop (iter, "s", &str)) 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_iter_free (iter);
g_variant_unref (result); g_variant_unref (result);
...@@ -476,7 +476,7 @@ call_helper_get_method_in_signature (GDBusConnection *c, ...@@ -476,7 +476,7 @@ call_helper_get_method_in_signature (GDBusConnection *c,
goto out; 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); node_info = g_dbus_node_info_new_for_xml (xml_data, error);
if (node_info == NULL) if (node_info == NULL)
goto out; goto out;
...@@ -1071,14 +1071,14 @@ dump_interface (GDBusConnection *c, ...@@ -1071,14 +1071,14 @@ dump_interface (GDBusConnection *c,
&iter); &iter);
while ((item = g_variant_iter_next_value (iter))) while ((item = g_variant_iter_next_value (iter)))
{ {
const gchar *key; gchar *key;
GVariant *value; GVariant *value;
g_variant_get (item, g_variant_get (item,
"{sv}", "{sv}",
&key, &key,
&value); &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); g_variant_unref (result);
...@@ -1354,7 +1354,7 @@ handle_introspect (gint *argc, ...@@ -1354,7 +1354,7 @@ handle_introspect (gint *argc,
g_variant_get_type_string (result)); g_variant_get_type_string (result));
goto out; goto out;
} }
g_variant_get (result, "(s)", &xml_data); g_variant_get (result, "(&s)", &xml_data);
error = NULL; error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error); node = g_dbus_node_info_new_for_xml (xml_data, &error);
......
...@@ -1839,7 +1839,6 @@ initable_init (GInitable *initable, ...@@ -1839,7 +1839,6 @@ initable_init (GInitable *initable,
if (connection->priv->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION) if (connection->priv->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION)
{ {
GVariant *hello_result; GVariant *hello_result;
const gchar *s;
hello_result = g_dbus_connection_call_sync (connection, hello_result = g_dbus_connection_call_sync (connection,
"org.freedesktop.DBus", /* name */ "org.freedesktop.DBus", /* name */
...@@ -1854,8 +1853,7 @@ initable_init (GInitable *initable, ...@@ -1854,8 +1853,7 @@ initable_init (GInitable *initable,
if (hello_result == NULL) if (hello_result == NULL)
goto out; goto out;
g_variant_get (hello_result, "(s)", &s); g_variant_get (hello_result, "(s)", &connection->priv->bus_unique_name);
connection->priv->bus_unique_name = g_strdup (s);
g_variant_unref (hello_result); g_variant_unref (hello_result);
//g_debug ("unique name is `%s'", connection->priv->bus_unique_name); //g_debug ("unique name is `%s'", connection->priv->bus_unique_name);
} }
...@@ -3217,12 +3215,12 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect ...@@ -3217,12 +3215,12 @@ validate_and_maybe_schedule_property_getset (GDBusConnection *connect
if (is_get) if (is_get)
g_variant_get (g_dbus_message_get_body (message), g_variant_get (g_dbus_message_get_body (message),
"(ss)", "(&s&s)",
&interface_name, &interface_name,
&property_name); &property_name);
else else
g_variant_get (g_dbus_message_get_body (message), g_variant_get (g_dbus_message_get_body (message),
"(ssv)", "(&s&sv)",
&interface_name, &interface_name,
&property_name, &property_name,
NULL); NULL);
...@@ -3321,12 +3319,12 @@ handle_getset_property (GDBusConnection *connection, ...@@ -3321,12 +3319,12 @@ handle_getset_property (GDBusConnection *connection,
if (is_get) if (is_get)
g_variant_get (g_dbus_message_get_body (message), g_variant_get (g_dbus_message_get_body (message),
"(ss)", "(&s&s)",
&interface_name, &interface_name,
&property_name); &property_name);
else else
g_variant_get (g_dbus_message_get_body (message), g_variant_get (g_dbus_message_get_body (message),
"(ssv)", "(&s&sv)",
&interface_name, &interface_name,
&property_name, &property_name,
NULL); NULL);
...@@ -3456,7 +3454,7 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection *connec ...@@ -3456,7 +3454,7 @@ validate_and_maybe_schedule_property_get_all (GDBusConnection *connec
handled = FALSE; handled = FALSE;
g_variant_get (g_dbus_message_get_body (message), g_variant_get (g_dbus_message_get_body (message),
"(s)", "(&s)",
&interface_name); &interface_name);
if (vtable == NULL || vtable->get_property == NULL) if (vtable == NULL || vtable->get_property == NULL)
...@@ -3498,7 +3496,7 @@ handle_get_all_properties (GDBusConnection *connection, ...@@ -3498,7 +3496,7 @@ handle_get_all_properties (GDBusConnection *connection,
handled = FALSE; handled = FALSE;
g_variant_get (g_dbus_message_get_body (message), g_variant_get (g_dbus_message_get_body (message),
"(s)", "(&s)",
&interface_name); &interface_name);
/* Fail with org.freedesktop.DBus.Error.InvalidArgs if there is /* Fail with org.freedesktop.DBus.Error.InvalidArgs if there is
...@@ -4651,11 +4649,11 @@ handle_subtree_method_invocation (GDBusConnection *connection, ...@@ -4651,11 +4649,11 @@ handle_subtree_method_invocation (GDBusConnection *connection,
else if (is_property_get || is_property_set || is_property_get_all) else if (is_property_get || is_property_set || is_property_get_all)
{ {
if (is_property_get) 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) 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) 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 else
g_assert_not_reached (); g_assert_not_reached ();
......
...@@ -2247,7 +2247,7 @@ g_dbus_message_to_gerror (GDBusMessage *message, ...@@ -2247,7 +2247,7 @@ g_dbus_message_to_gerror (GDBusMessage *message,
if (body != NULL && g_variant_is_of_type (body, G_VARIANT_TYPE ("(s)"))) if (body != NULL && g_variant_is_of_type (body, G_VARIANT_TYPE ("(s)")))
{ {
const gchar *error_message; 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, g_dbus_error_set_dbus_error (error,
error_name, error_name,
error_message, error_message,
......
...@@ -261,7 +261,7 @@ on_name_lost_or_acquired (GDBusConnection *connection, ...@@ -261,7 +261,7 @@ on_name_lost_or_acquired (GDBusConnection *connection,
if (g_strcmp0 (signal_name, "NameLost") == 0) 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) if (g_strcmp0 (name, client->name) == 0)
{ {
call_lost_handler (client); call_lost_handler (client);
...@@ -269,7 +269,7 @@ on_name_lost_or_acquired (GDBusConnection *connection, ...@@ -269,7 +269,7 @@ on_name_lost_or_acquired (GDBusConnection *connection,
} }
else if (g_strcmp0 (signal_name, "NameAcquired") == 0) 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) if (g_strcmp0 (name, client->name) == 0)
{ {
call_acquired_handler (client); call_acquired_handler (client);
......
...@@ -289,7 +289,7 @@ on_name_owner_changed (GDBusConnection *connection, ...@@ -289,7 +289,7 @@ on_name_owner_changed (GDBusConnection *connection,
goto out; goto out;
g_variant_get (parameters, g_variant_get (parameters,
"(sss)", "(&s&s&s)",
&name, &name,
&old_owner, &old_owner,
&new_owner); &new_owner);
...@@ -336,7 +336,7 @@ get_name_owner_cb (GObject *source_object, ...@@ -336,7 +336,7 @@ get_name_owner_cb (GObject *source_object,
NULL); NULL);
if (result != NULL) if (result != NULL)
{ {
g_variant_get (result, "(s)", &name_owner); g_variant_get (result, "(&s)", &name_owner);
} }
if (name_owner != NULL) if (name_owner != NULL)
......
...@@ -848,7 +848,7 @@ process_get_all_reply (GDBusProxy *proxy, ...@@ -848,7 +848,7 @@ process_get_all_reply (GDBusProxy *proxy,
g_variant_iter_init (&iter, g_variant_get_child_value (result, 0)); g_variant_iter_init (&iter, g_variant_get_child_value (result, 0));
while ((item = g_variant_iter_next_value (&iter)) != NULL) while ((item = g_variant_iter_next_value (&iter)) != NULL)
{ {
const gchar *key; gchar *key;
GVariant *value; GVariant *value;
g_variant_get (item, g_variant_get (item,
...@@ -858,7 +858,7 @@ process_get_all_reply (GDBusProxy *proxy, ...@@ -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_print ("got %s -> %s\n", key, g_variant_markup_print (value, FALSE, 0, 0));
g_hash_table_insert (proxy->priv->properties, g_hash_table_insert (proxy->priv->properties,
g_strdup (key), key,
value); /* steals value */ value); /* steals value */
} }
out: out:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment