bus: Don't explicitly clear BusConnections.monitors
authorSimon McVittie <smcv@collabora.com>
Thu, 20 Feb 2020 00:36:53 +0000 (00:36 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 25 Feb 2020 12:50:08 +0000 (12:50 +0000)
commit2c6b0ad7f6bc0727717d455894f51cbb39b77bf3
treece9b74600d57dcab1dc9f2bc6b8b3acab9ef6896
parentdf0c675b93c9521e1264ce906a70f239923c5b61
bus: Don't explicitly clear BusConnections.monitors

Each connection that is an active monitor holds a pointer to its own
link in this list, via BusConnectionData.link_in_monitors. We can't
validly free the list while these pointers exist: that would be a
use-after-free, when each connection gets disconnected and tries to
remove itself from the list.

Instead, let each connection remove itself from the list, then assert
that the list has become empty.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/291

(cherry picked from commit b034b83b59efffd4cc819ad42d0cd078d91d53df)
bus/connection.c