diff --git a/emulator/btdev.c b/emulator/btdev.c
index 8c72a24..c53db70 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
{
const struct bt_hci_cmd_le_term_big *cmd = data;
struct bt_hci_evt_le_big_terminate rsp;
- struct le_big *big;
+ struct le_big *big, *rbig;
struct btdev_conn *conn;
struct btdev *remote = NULL;
big = queue_find(dev->le_big, match_big_handle,
UINT_TO_PTR(cmd->handle));
-
if (!big)
return 0;
remote = conn->link->dev;
- big = queue_find(remote->le_big, match_bis, conn->link);
- if (big) {
+ rbig = queue_find(remote->le_big, match_bis,
+ conn->link);
+ if (rbig) {
memset(&evt, 0, sizeof(evt));
- evt.big_handle = big->handle;
+ evt.big_handle = rbig->handle;
evt.reason = cmd->reason;
le_meta_event(remote,
BT_HCI_EVT_LE_BIG_SYNC_LOST,
&evt, sizeof(evt));
+ queue_remove(remote->le_big, rbig);
+ le_big_free(rbig);
}
}