mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
GDBus: plug some memory leaks
These fixes makes udisks-daemon from udisks' gdbus-port branch, see http://cgit.freedesktop.org/udisks/log/?h=gdbus-port handle 200 add/remove uevents generated by e.g. #!/bin/bash DEV=mmcblk0p1 for n in `seq 200` ; do udevadm trigger --sysname-match=$DEV --action=remove udevadm trigger --sysname-match=$DEV --action=add echo foo $n done without any substantial leaks. Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
40d5da99d6
commit
21d7ce97c3
@ -607,6 +607,8 @@ _g_dbus_auth_run_client (GDBusAuth *auth,
|
|||||||
|
|
||||||
dis = G_DATA_INPUT_STREAM (g_data_input_stream_new (g_io_stream_get_input_stream (auth->priv->stream)));
|
dis = G_DATA_INPUT_STREAM (g_data_input_stream_new (g_io_stream_get_input_stream (auth->priv->stream)));
|
||||||
dos = G_DATA_OUTPUT_STREAM (g_data_output_stream_new (g_io_stream_get_output_stream (auth->priv->stream)));
|
dos = G_DATA_OUTPUT_STREAM (g_data_output_stream_new (g_io_stream_get_output_stream (auth->priv->stream)));
|
||||||
|
g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (dis), FALSE);
|
||||||
|
g_filter_output_stream_set_close_base_stream (G_FILTER_OUTPUT_STREAM (dos), FALSE);
|
||||||
|
|
||||||
g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
|
g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
|
||||||
|
|
||||||
@ -863,8 +865,8 @@ _g_dbus_auth_run_client (GDBusAuth *auth,
|
|||||||
g_object_unref (mech);
|
g_object_unref (mech);
|
||||||
g_ptr_array_unref (attempted_auth_mechs);
|
g_ptr_array_unref (attempted_auth_mechs);
|
||||||
g_strfreev (supported_auth_mechs);
|
g_strfreev (supported_auth_mechs);
|
||||||
g_object_ref (dis);
|
g_object_unref (dis);
|
||||||
g_object_ref (dos);
|
g_object_unref (dos);
|
||||||
|
|
||||||
/* ensure return value is NULL if error is set */
|
/* ensure return value is NULL if error is set */
|
||||||
if (error != NULL && *error != NULL)
|
if (error != NULL && *error != NULL)
|
||||||
@ -972,6 +974,8 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
|||||||
|
|
||||||
dis = G_DATA_INPUT_STREAM (g_data_input_stream_new (g_io_stream_get_input_stream (auth->priv->stream)));
|
dis = G_DATA_INPUT_STREAM (g_data_input_stream_new (g_io_stream_get_input_stream (auth->priv->stream)));
|
||||||
dos = G_DATA_OUTPUT_STREAM (g_data_output_stream_new (g_io_stream_get_output_stream (auth->priv->stream)));
|
dos = G_DATA_OUTPUT_STREAM (g_data_output_stream_new (g_io_stream_get_output_stream (auth->priv->stream)));
|
||||||
|
g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (dis), FALSE);
|
||||||
|
g_filter_output_stream_set_close_base_stream (G_FILTER_OUTPUT_STREAM (dos), FALSE);
|
||||||
|
|
||||||
g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
|
g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
|
||||||
|
|
||||||
@ -1324,9 +1328,9 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
|||||||
if (mech != NULL)
|
if (mech != NULL)
|
||||||
g_object_unref (mech);
|
g_object_unref (mech);
|
||||||
if (dis != NULL)
|
if (dis != NULL)
|
||||||
g_object_ref (dis);
|
g_object_unref (dis);
|
||||||
if (dis != NULL)
|
if (dos != NULL)
|
||||||
g_object_ref (dos);
|
g_object_unref (dos);
|
||||||
|
|
||||||
/* ensure return value is FALSE if error is set */
|
/* ensure return value is FALSE if error is set */
|
||||||
if (error != NULL && *error != NULL)
|
if (error != NULL && *error != NULL)
|
||||||
|
@ -763,6 +763,8 @@ read_string (GMemoryInputStream *mis,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if just_align==TRUE, don't read a value, just align the input stream wrt padding */
|
/* if just_align==TRUE, don't read a value, just align the input stream wrt padding */
|
||||||
|
|
||||||
|
/* returns a non-floating GVariant! */
|
||||||
static GVariant *
|
static GVariant *
|
||||||
parse_value_from_blob (GMemoryInputStream *mis,
|
parse_value_from_blob (GMemoryInputStream *mis,
|
||||||
GDataInputStream *dis,
|
GDataInputStream *dis,
|
||||||
@ -1053,6 +1055,7 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
g_variant_builder_add_value (&builder, item);
|
g_variant_builder_add_value (&builder, item);
|
||||||
|
g_variant_unref (item);
|
||||||
offset = g_seekable_tell (G_SEEKABLE (mis));
|
offset = g_seekable_tell (G_SEEKABLE (mis));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1092,7 +1095,6 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
&local_error);
|
&local_error);
|
||||||
if (key == NULL)
|
if (key == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
value_type = g_variant_type_value (type);
|
value_type = g_variant_type_value (type);
|
||||||
value = parse_value_from_blob (mis,
|
value = parse_value_from_blob (mis,
|
||||||
dis,
|
dis,
|
||||||
@ -1106,6 +1108,8 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
ret = g_variant_new_dict_entry (key, value);
|
ret = g_variant_new_dict_entry (key, value);
|
||||||
|
g_variant_unref (key);
|
||||||
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_variant_type_is_tuple (type))
|
else if (g_variant_type_is_tuple (type))
|
||||||
@ -1140,6 +1144,7 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
g_variant_builder_add_value (&builder, item);
|
g_variant_builder_add_value (&builder, item);
|
||||||
|
g_variant_unref (item);
|
||||||
|
|
||||||
element_type = g_variant_type_next (element_type);
|
element_type = g_variant_type_next (element_type);
|
||||||
}
|
}
|
||||||
@ -1188,6 +1193,7 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
ret = g_variant_new_variant (value);
|
ret = g_variant_new_variant (value);
|
||||||
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1225,6 +1231,12 @@ parse_value_from_blob (GMemoryInputStream *mis,
|
|||||||
}
|
}
|
||||||
#endif /* DEBUG_SERIALIZER */
|
#endif /* DEBUG_SERIALIZER */
|
||||||
|
|
||||||
|
/* sink the reference */
|
||||||
|
if (ret != NULL)
|
||||||
|
{
|
||||||
|
g_assert (g_variant_is_floating (ret));
|
||||||
|
g_variant_ref_sink (ret);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
@ -1413,9 +1425,8 @@ g_dbus_message_new_from_blob (guchar *blob,
|
|||||||
error);
|
error);
|
||||||
if (headers == NULL)
|
if (headers == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
g_variant_ref_sink (headers);
|
|
||||||
g_variant_iter_init (&iter, headers);
|
g_variant_iter_init (&iter, headers);
|
||||||
while ((item = g_variant_iter_next_value (&iter)))
|
while ((item = g_variant_iter_next_value (&iter)) != NULL)
|
||||||
{
|
{
|
||||||
guchar header_field;
|
guchar header_field;
|
||||||
GVariant *value;
|
GVariant *value;
|
||||||
@ -1424,6 +1435,8 @@ g_dbus_message_new_from_blob (guchar *blob,
|
|||||||
&header_field,
|
&header_field,
|
||||||
&value);
|
&value);
|
||||||
g_dbus_message_set_header (message, header_field, value);
|
g_dbus_message_set_header (message, header_field, value);
|
||||||
|
g_variant_unref (value);
|
||||||
|
g_variant_unref (item);
|
||||||
}
|
}
|
||||||
g_variant_unref (headers);
|
g_variant_unref (headers);
|
||||||
|
|
||||||
@ -1471,13 +1484,9 @@ g_dbus_message_new_from_blob (guchar *blob,
|
|||||||
FALSE,
|
FALSE,
|
||||||
2,
|
2,
|
||||||
error);
|
error);
|
||||||
if (message->priv->body == NULL)
|
|
||||||
{
|
|
||||||
g_variant_type_free (variant_type);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
g_variant_ref_sink (message->priv->body);
|
|
||||||
g_variant_type_free (variant_type);
|
g_variant_type_free (variant_type);
|
||||||
|
if (message->priv->body == NULL)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1716,7 +1725,7 @@ append_value_to_blob (GVariant *value,
|
|||||||
guint n;
|
guint n;
|
||||||
n = 0;
|
n = 0;
|
||||||
g_variant_iter_init (&iter, value);
|
g_variant_iter_init (&iter, value);
|
||||||
while ((item = g_variant_iter_next_value (&iter)))
|
while ((item = g_variant_iter_next_value (&iter)) != NULL)
|
||||||
{
|
{
|
||||||
gsize padding_added_for_item;
|
gsize padding_added_for_item;
|
||||||
if (!append_value_to_blob (item,
|
if (!append_value_to_blob (item,
|
||||||
@ -1725,7 +1734,11 @@ append_value_to_blob (GVariant *value,
|
|||||||
dos,
|
dos,
|
||||||
&padding_added_for_item,
|
&padding_added_for_item,
|
||||||
error))
|
error))
|
||||||
goto fail;
|
{
|
||||||
|
g_variant_unref (item);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
g_variant_unref (item);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
array_payload_begin_offset += padding_added_for_item;
|
array_payload_begin_offset += padding_added_for_item;
|
||||||
@ -1755,7 +1768,7 @@ append_value_to_blob (GVariant *value,
|
|||||||
GVariant *item;
|
GVariant *item;
|
||||||
GVariantIter iter;
|
GVariantIter iter;
|
||||||
g_variant_iter_init (&iter, value);
|
g_variant_iter_init (&iter, value);
|
||||||
while ((item = g_variant_iter_next_value (&iter)))
|
while ((item = g_variant_iter_next_value (&iter)) != NULL)
|
||||||
{
|
{
|
||||||
if (!append_value_to_blob (item,
|
if (!append_value_to_blob (item,
|
||||||
g_variant_get_type (item),
|
g_variant_get_type (item),
|
||||||
@ -1763,7 +1776,11 @@ append_value_to_blob (GVariant *value,
|
|||||||
dos,
|
dos,
|
||||||
NULL,
|
NULL,
|
||||||
error))
|
error))
|
||||||
goto fail;
|
{
|
||||||
|
g_variant_unref (item);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
g_variant_unref (item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1833,7 +1850,7 @@ append_body_to_blob (GVariant *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_variant_iter_init (&iter, value);
|
g_variant_iter_init (&iter, value);
|
||||||
while ((item = g_variant_iter_next_value (&iter)))
|
while ((item = g_variant_iter_next_value (&iter)) != NULL)
|
||||||
{
|
{
|
||||||
if (!append_value_to_blob (item,
|
if (!append_value_to_blob (item,
|
||||||
g_variant_get_type (item),
|
g_variant_get_type (item),
|
||||||
@ -1841,7 +1858,11 @@ append_body_to_blob (GVariant *value,
|
|||||||
dos,
|
dos,
|
||||||
NULL,
|
NULL,
|
||||||
error))
|
error))
|
||||||
goto fail;
|
{
|
||||||
|
g_variant_unref (item);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
g_variant_unref (item);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -2454,6 +2475,7 @@ g_dbus_message_get_arg0 (GDBusMessage *message)
|
|||||||
item = g_variant_get_child_value (message->priv->body, 0);
|
item = g_variant_get_child_value (message->priv->body, 0);
|
||||||
if (g_variant_is_of_type (item, G_VARIANT_TYPE_STRING))
|
if (g_variant_is_of_type (item, G_VARIANT_TYPE_STRING))
|
||||||
ret = g_variant_get_string (item, NULL);
|
ret = g_variant_get_string (item, NULL);
|
||||||
|
g_variant_unref (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -119,6 +119,7 @@ read_with_control_data_free (ReadWithControlData *data)
|
|||||||
g_object_unref (data->socket);
|
g_object_unref (data->socket);
|
||||||
if (data->cancellable != NULL)
|
if (data->cancellable != NULL)
|
||||||
g_object_unref (data->cancellable);
|
g_object_unref (data->cancellable);
|
||||||
|
g_object_unref (data->simple);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user