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>
pull/9256/head
Jim Mussared 2022-08-09 16:48:04 +10:00 zatwierdzone przez Damien George
rodzic 6e75d177e7
commit 82fc16f298
1 zmienionych plików z 27 dodań i 29 usunięć

Wyświetl plik

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