extmod/modbluetooth: Fix descriptor registration with empty tuple.
Incorrect use of "continue" when the tuple was length zero meant it broke the rest of the argument handling. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
6e75d177e7
commit
82fc16f298
@ -529,12 +529,9 @@ STATIC int bluetooth_gatts_register_service(mp_obj_t uuid_in, mp_obj_t character
|
||||
|
||||
// Optional third element, iterable of descriptors.
|
||||
if (characteristic_len >= 3) {
|
||||
mp_obj_t descriptors_len_in = mp_obj_len(characteristic_items[2]);
|
||||
num_descriptors[characteristic_index] = mp_obj_get_int(descriptors_len_in);
|
||||
|
||||
if (num_descriptors[characteristic_index] == 0) {
|
||||
continue;
|
||||
}
|
||||
mp_int_t n = mp_obj_get_int(mp_obj_len(characteristic_items[2]));
|
||||
if (n) {
|
||||
num_descriptors[characteristic_index] = n;
|
||||
|
||||
// Grow the flattened uuids and flags arrays with this many more descriptors.
|
||||
descriptor_uuids = m_renew(mp_obj_bluetooth_uuid_t *, descriptor_uuids, descriptor_index, descriptor_index + num_descriptors[characteristic_index]);
|
||||
@ -567,6 +564,7 @@ STATIC int bluetooth_gatts_register_service(mp_obj_t uuid_in, mp_obj_t character
|
||||
// Reflect that we've grown the handles array.
|
||||
*num_handles += num_descriptors[characteristic_index];
|
||||
}
|
||||
}
|
||||
|
||||
characteristic_uuids[characteristic_index] = MP_OBJ_TO_PTR(uuid_obj);
|
||||
characteristic_flags[characteristic_index] = mp_obj_get_int(characteristic_items[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user