Skip to content

Commit 8950cc2

Browse files
committed
Patch for zmkfirmware#1243: avoid write to uninitialized handle
In split_central_update_indicators_callback, it seems that the peripheral is sometimes considered connected before the GATT characteristics have been discovered. If this is the case, the update_hid_indicators handle will not yet be set, and must not be written to.
1 parent b24e4f2 commit 8950cc2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/split/bluetooth/central.c

+7
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,13 @@ static void split_central_update_indicators_callback(struct k_work *work) {
713713
continue;
714714
}
715715

716+
if (peripherals[i].update_hid_indicators == 0) {
717+
// It appears that sometimes the peripheral is considered connected
718+
// before the GATT characteristics have been discovered. If this is
719+
// the case, the update_hid_indicators handle will not yet be set.
720+
continue;
721+
}
722+
716723
int err = bt_gatt_write_without_response(peripherals[i].conn,
717724
peripherals[i].update_hid_indicators, &indicators,
718725
sizeof(indicators), true);

0 commit comments

Comments
 (0)