mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
don't get service_record_item_t for record_handle = 0, fix another bug in sdp_unregister_services_for_connection
This commit is contained in:
parent
d2acb74537
commit
b63955969a
12
src/sdp.c
12
src/sdp.c
@ -120,7 +120,11 @@ uint32_t sdp_register_service_internal(connection_t *connection, uint8_t * recor
|
||||
if (record_handle <= maxReservedServiceRecordHandle) record_handle = 0;
|
||||
|
||||
// check if already in use
|
||||
if (sdp_get_record_for_handle(record_handle)) record_handle = 0;
|
||||
if (record_handle) {
|
||||
if (sdp_get_record_for_handle(record_handle)) {
|
||||
record_handle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// create new handle if needed
|
||||
if (!record_handle){
|
||||
@ -162,7 +166,6 @@ uint32_t sdp_register_service_internal(connection_t *connection, uint8_t * recor
|
||||
|
||||
// add to linked list
|
||||
linked_list_add(&sdp_service_records, (linked_item_t *) newRecordItem);
|
||||
|
||||
return record_handle;
|
||||
}
|
||||
|
||||
@ -181,9 +184,10 @@ void sdp_unregister_service_internal(connection_t *connection, uint32_t service_
|
||||
void sdp_unregister_services_for_connection(connection_t *connection){
|
||||
linked_item_t *it = (linked_item_t *) &sdp_service_records;
|
||||
while (it->next){
|
||||
if (((service_record_item_t *)it->next)->connection == connection){
|
||||
if (((service_record_item_t *)(it->next))->connection == connection){
|
||||
linked_item_t *toDelete = it->next;
|
||||
it->next = it->next->next;
|
||||
free(it->next);
|
||||
free(toDelete);
|
||||
} else {
|
||||
it = it->next;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user