diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2022-03-07 16:38:25 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-04-21 13:55:59 +0100 |
commit | b90b838c93fbfba4476901fddcff50d23cd4b108 (patch) | |
tree | 1dbdd6bf96cb9a8cba609add1f92172555d633c6 | |
parent | 21a6441f33bcf8cc7749af3d0d1dfc874e4a5c99 (diff) | |
download | dbus-b90b838c93fbfba4476901fddcff50d23cd4b108.tar.gz |
bus_service_remove_owner(): Assert that service has an owner
gcc 10.3 warns that link->data is a possible NULL dereference.
However, that can't actually happen without an earlier programming
error, because bus_service_remove_owner() is only valid to call for
a connection that is currently in the queue to own the service,
in which case we know _bus_service_find_owner_link() will succeed.
Part-of: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/275
Reviewed-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | bus/services.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bus/services.c b/bus/services.c index a7dd181e..cd2fb1c4 100644 --- a/bus/services.c +++ b/bus/services.c @@ -1148,6 +1148,10 @@ bus_service_remove_owner (BusService *service, BusOwner *temp_owner; link = _bus_service_find_owner_link (service, connection); + /* This function is only valid to call if connection owns service. + * If that's the case, we should always find connection in the + * list of owners. */ + _dbus_assert (link != NULL); _dbus_list_unlink (&service->owners, link); temp_owner = (BusOwner *)link->data; bus_owner_unref (temp_owner); |