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.
This commit is contained in:
Johan Hedberg 2010-12-09 21:52:54 +02:00 committed by Marcel Holtmann
parent 4a90a2666c
commit a437bfba54
1 changed files with 5 additions and 5 deletions

View File

@ -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);
}