spa: bluez: backend-native: fix a memory leak

In `_transport_create()`, if `spa_bt_transport_create()` failed
then `pathfd` would be leaked.
This commit is contained in:
Barnabás Pőcze 2023-06-23 22:53:39 +02:00
parent 2efccb3d01
commit 4a555ed6ff

View file

@ -216,8 +216,10 @@ static struct spa_bt_transport *_transport_create(struct rfcomm *rfcomm)
return NULL;
t = spa_bt_transport_create(backend->monitor, pathfd, sizeof(struct transport_data));
if (t == NULL)
goto finish;
if (t == NULL) {
free(pathfd);
return NULL;
}
spa_bt_transport_set_implementation(t, &sco_transport_impl, t);
t->device = rfcomm->device;
@ -248,7 +250,6 @@ static struct spa_bt_transport *_transport_create(struct rfcomm *rfcomm)
spa_bt_transport_add_listener(t, &rfcomm->transport_listener, &transport_events, rfcomm);
finish:
return t;
}