From bc64b32798a4e9397fdadd07be55d7d18c2b4887 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 12 May 2021 15:33:33 +1000 Subject: [PATCH] bluez: fix a memleak on error If the allocation failed, our strdup'ed path would leak. Found by scan-build --- spa/plugins/bluez5/bluez5-dbus.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index b75060dc7..b04360ee0 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -2534,9 +2534,13 @@ static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn, is_new = transport == NULL; if (is_new) { - transport = spa_bt_transport_create(monitor, strdup(transport_path), 0); - if (transport == NULL) + char *path = strdup(transport_path); + + transport = spa_bt_transport_create(monitor, path, 0); + if (transport == NULL) { + free(path); return DBUS_HANDLER_RESULT_NEED_MEMORY; + } spa_bt_transport_set_implementation(transport, &transport_impl, transport);