mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_dangling_pointer_in_remove_bond_list_section_v5.0' into 'release/v5.0'
fix(bt/bluedroid): fix dangling pointer issue when logging removed section (backport v5.0) See merge request espressif/esp-idf!28963
This commit is contained in:
commit
646658a564
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -57,7 +57,8 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
||||
|
||||
// delete config info
|
||||
if (btc_config_remove_section(remove_section)) {
|
||||
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %s\n", remove_section);
|
||||
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,6 +132,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
bt_status_t status = BT_STATUS_FAIL;
|
||||
uint16_t dev_cnt = 0;
|
||||
const btc_config_section_iter_t *remove_iter = NULL;
|
||||
bt_bdaddr_t bd_addr;
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end(); iter = btc_config_section_next(iter)) {
|
||||
@ -157,6 +159,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
remove_iter = iter;
|
||||
while (remove_iter != btc_config_section_end()) {
|
||||
const char *remove_section = btc_config_section_name(remove_iter);
|
||||
string_to_bdaddr(remove_section, &bd_addr);
|
||||
if (!string_is_bdaddr(remove_section)) {
|
||||
remove_iter = btc_config_section_next(remove_iter);
|
||||
continue;
|
||||
@ -164,7 +167,8 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
remove_iter = btc_config_section_next(remove_iter);
|
||||
/* delete config info */
|
||||
if (btc_config_remove_section(remove_section)) {
|
||||
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the exceed device info : %s", remove_section);
|
||||
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the exceed device info : %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
||||
}
|
||||
}
|
||||
/* write into nvs */
|
||||
|
Loading…
Reference in New Issue
Block a user