From 0b26078152cc143572ad89f2691bd695264eea7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 1 May 2020 15:14:40 +0200 Subject: [PATCH] bluetooth: Fix crash when destroying transports Ensure that transport has still allocated memory when hooks (triggered by pa_bluetooth_transport_set_state) are calling --- src/modules/bluetooth/bluez5-util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c index 0022e4d66..09922ba06 100644 --- a/src/modules/bluetooth/bluez5-util.c +++ b/src/modules/bluetooth/bluez5-util.c @@ -425,10 +425,11 @@ void pa_bluetooth_transport_put(pa_bluetooth_transport *t) { void pa_bluetooth_transport_free(pa_bluetooth_transport *t) { pa_assert(t); + pa_bluetooth_transport_set_state(t, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED); + if (t->destroy) t->destroy(t); - pa_bluetooth_transport_set_state(t, PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED); pa_hashmap_remove(t->device->discovery->transports, t->path); t->device->transports[t->profile] = NULL; -- GitLab