summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-07-06 16:09:17 +0200
committerMax Kellermann <max@musicpd.org>2020-07-06 16:15:18 +0200
commit6517b2d2acedb7226802b423e2131f83a693d3be (patch)
tree2f978314a38c41f0c8b88ac6d57ebc6c2200724d
parentbfdf13dca365fb6ac9a5912d6a1a9efb08b2e361 (diff)
neighbor/upnp: remove D-Bus filter and match in Close()
Fixes use-after-free crash bug during MPD shutdown.
-rw-r--r--NEWS2
-rw-r--r--src/neighbor/plugins/UdisksNeighborPlugin.cxx17
2 files changed, 12 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index d4e05e837..a515aeaad 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ ver 0.21.25 (not yet released)
* output
- osx: improve sample rate selection
- osx: fix noise while stopping
+* neighbor
+ - upnp: fix crash during shutdown
* Windows/Android:
- fix Boost detection after breaking change in Meson 0.54
diff --git a/src/neighbor/plugins/UdisksNeighborPlugin.cxx b/src/neighbor/plugins/UdisksNeighborPlugin.cxx
index cb5d422f2..359d16ef3 100644
--- a/src/neighbor/plugins/UdisksNeighborPlugin.cxx
+++ b/src/neighbor/plugins/UdisksNeighborPlugin.cxx
@@ -47,6 +47,11 @@ ToNeighborInfo(const UDisks2::Object &o) noexcept
return {o.GetUri(), o.path};
}
+static constexpr char udisks_neighbor_match[] =
+ "type='signal',sender='" UDISKS2_INTERFACE "',"
+ "interface='" DBUS_OM_INTERFACE "',"
+ "path='" UDISKS2_PATH "'";
+
class UdisksNeighborExplorer final
: public NeighborExplorer {
@@ -110,11 +115,7 @@ UdisksNeighborExplorer::DoOpen()
try {
Error error;
- dbus_bus_add_match(connection,
- "type='signal',sender='" UDISKS2_INTERFACE "',"
- "interface='" DBUS_OM_INTERFACE "',"
- "path='" UDISKS2_PATH "'",
- error);
+ dbus_bus_add_match(connection, udisks_neighbor_match, error);
error.CheckThrow("DBus AddMatch error");
dbus_connection_add_filter(connection,
@@ -147,8 +148,10 @@ UdisksNeighborExplorer::DoClose() noexcept
list_request.Cancel();
}
- // TODO: remove_match
- // TODO: remove_filter
+ auto &connection = GetConnection();
+
+ dbus_connection_remove_filter(connection, HandleMessage, this);
+ dbus_bus_remove_match(connection, udisks_neighbor_match, nullptr);
dbus_glue.Destruct();
}