Always assert that BUS_CONNECTION_DATA() returns non-NULL
authorRalf Habacker <ralf.habacker@freenet.de>
Tue, 14 Apr 2015 21:17:40 +0000 (23:17 +0200)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 17 Apr 2015 12:07:05 +0000 (13:07 +0100)
commitd5e7e2794ecc213f5e3332a3bc36aa1708bdb637
treea6a67a406c825c1494bbf0d0b5df668d023038a4
parent26a3c0dc5b2ad10e22a0c5b4a745e5b008bee2b7
Always assert that BUS_CONNECTION_DATA() returns non-NULL

Every DBusConnection in the dbus-daemon should have been through
bus_connections_setup_connection(), so we can assert that the
BusConnectionData has been attached to it. Having this assertion
is enough to hint to Coverity that it does not need to worry about
whether this pointer might be NULL.

In regression tests, we do work with a few fake client-side
DBusConnection instances in the same process; but it would be a
serious bug if we mixed those up with the ones processed by
dbus-daemon's real code, so the assertion is still valid.

This patch has been inspired by (and fixes) the following coverity scan issues:
CID 54846: Dereference null return value (NULL_RETURNS).
CID 54854: Dereference null return value (NULL_RETURNS).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: fixed -Wdeclaration-after-statement; more informative commit message]
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
bus/connection.c