Skip to content

Commit 4fb2310

Browse files
committed
Merge branch 'bugfix/fix_dangling_pointer_in_remove_bond_list_section' into 'master'
fix(bt/bluedroid): fix dangling pointer issue when logging removed section See merge request espressif/esp-idf!28734
2 parents a2e5770 + 3f205d4 commit 4fb2310

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: components/bt/host/bluedroid/btc/core/btc_storage.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -57,7 +57,8 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
5757

5858
// delete config info
5959
if (btc_config_remove_section(remove_section)) {
60-
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %s\n", remove_section);
60+
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
61+
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
6162
}
6263
}
6364

@@ -131,6 +132,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
131132
bt_status_t status = BT_STATUS_FAIL;
132133
uint16_t dev_cnt = 0;
133134
const btc_config_section_iter_t *remove_iter = NULL;
135+
bt_bdaddr_t bd_addr;
134136

135137
btc_config_lock();
136138
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end(); iter = btc_config_section_next(iter)) {
@@ -157,14 +159,16 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
157159
remove_iter = iter;
158160
while (remove_iter != btc_config_section_end()) {
159161
const char *remove_section = btc_config_section_name(remove_iter);
162+
string_to_bdaddr(remove_section, &bd_addr);
160163
if (!string_is_bdaddr(remove_section)) {
161164
remove_iter = btc_config_section_next(remove_iter);
162165
continue;
163166
}
164167
remove_iter = btc_config_section_next(remove_iter);
165168
/* delete config info */
166169
if (btc_config_remove_section(remove_section)) {
167-
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the exceed device info : %s", remove_section);
170+
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the exceed device info : %02x:%02x:%02x:%02x:%02x:%02x",
171+
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
168172
}
169173
}
170174
/* write into nvs */

0 commit comments

Comments
 (0)