From 4a555ed6ff31316c99a4523f60ed45a66b7aed3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Fri, 23 Jun 2023 22:53:39 +0200 Subject: [PATCH] spa: bluez: backend-native: fix a memory leak In `_transport_create()`, if `spa_bt_transport_create()` failed then `pathfd` would be leaked. --- spa/plugins/bluez5/backend-native.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c index 0d2199107..db8ba2ca1 100644 --- a/spa/plugins/bluez5/backend-native.c +++ b/spa/plugins/bluez5/backend-native.c @@ -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; }