summaryrefslogtreecommitdiff
path: root/gdbus/watch.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2010-12-09 21:52:54 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-12-10 00:07:30 +0100
commit4abf29afdfd527c3ddd450972cf0bf6d4e823f09 (patch)
tree429f0088239d8a1ad074831f02f22f4722478b88 /gdbus/watch.c
parentbf8cdb5ab9def0ee6570886146c400f0e408f3e4 (diff)
downloadconnman-4abf29afdfd527c3ddd450972cf0bf6d4e823f09.tar.gz
connman-4abf29afdfd527c3ddd450972cf0bf6d4e823f09.tar.bz2
connman-4abf29afdfd527c3ddd450972cf0bf6d4e823f09.zip
gdbus: fix accessing freed callback data
cb->disc_func or cb->conn_func could remove the callback so this needs to be checked for before continuing processing.
Diffstat (limited to 'gdbus/watch.c')
-rw-r--r--gdbus/watch.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gdbus/watch.c b/gdbus/watch.c
index e7c203ae..9cb7ec70 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -477,6 +477,11 @@ static DBusHandlerResult service_filter(DBusConnection *connection,
cb->conn_func(connection, cb->user_data);
}
+ /* Check if the watch was removed/freed by the callback
+ * function */
+ if (!g_slist_find(data->callbacks, cb))
+ continue;
+
/* Only auto remove if it is a bus name watch */
if (data->argument[0] == ':' &&
(cb->conn_func == NULL || cb->disc_func == NULL)) {
@@ -484,11 +489,6 @@ static DBusHandlerResult service_filter(DBusConnection *connection,
continue;
}
- /* Check if the watch was removed/freed by the callback
- * function */
- if (!g_slist_find(data->callbacks, cb))
- continue;
-
data->callbacks = g_slist_remove(data->callbacks, cb);
data->processed = g_slist_append(data->processed, cb);
}