summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-10-10 21:06:42 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-10-10 21:14:48 +0200
commitdf87c30e93477e0d79bede0cc4973c2a6ef2ef87 (patch)
tree76e23b2987fa4e5a25415669ea53c3ef1cb68235
parent1fd2385c524b84b2aaa0b39c7b28bc01abed1687 (diff)
libqmi-glib,device: avoid invalid reads in the sync indication callback
If we don't disconnect the signal handler when we clear the private QmiClientCtl, we may end up in the situation where we try to use the already disposed QmiDevice object.
-rw-r--r--libqmi-glib/qmi-device.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libqmi-glib/qmi-device.c b/libqmi-glib/qmi-device.c
index e8d801c..1c4c567 100644
--- a/libqmi-glib/qmi-device.c
+++ b/libqmi-glib/qmi-device.c
@@ -71,6 +71,7 @@ struct _QmiDevicePrivate {
/* Implicit CTL client */
QmiClientCtl *client_ctl;
+ guint sync_indication_id;
/* Supported services */
GArray *supported_services;
@@ -1927,10 +1928,11 @@ query_info_async_ready (GFile *file,
g_assert_no_error (error);
/* Connect to 'Sync' indications */
- g_signal_connect (ctx->self->priv->client_ctl,
- "sync",
- G_CALLBACK (sync_indication_cb),
- ctx->self);
+ ctx->self->priv->sync_indication_id =
+ g_signal_connect (ctx->self->priv->client_ctl,
+ "sync",
+ G_CALLBACK (sync_indication_cb),
+ ctx->self);
/* Done we are */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
@@ -2061,6 +2063,12 @@ dispose (GObject *object)
(GHRFunc)foreach_warning,
self);
+ if (self->priv->sync_indication_id &&
+ self->priv->client_ctl) {
+ g_signal_handler_disconnect (self->priv->client_ctl,
+ self->priv->sync_indication_id);
+ self->priv->sync_indication_id = 0;
+ }
g_clear_object (&self->priv->client_ctl);
G_OBJECT_CLASS (qmi_device_parent_class)->dispose (object);