bluez: fix a memleak on error

If the allocation failed, our strdup'ed path would leak.

Found by scan-build
This commit is contained in:
Peter Hutterer 2021-05-12 15:33:33 +10:00 committed by Wim Taymans
parent b64f0d581f
commit bc64b32798

View file

@ -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);