From b11b9dabb3c6b3c5cf65f3a9e1f2717e3d92fd3d Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Sat, 20 Jan 2024 16:35:38 +0800 Subject: [PATCH] fix(ble/bluedroid): Fix dangling pointer issue in deletion of bonded devices --- components/bt/host/bluedroid/btc/core/btc_ble_storage.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/btc/core/btc_ble_storage.c b/components/bt/host/bluedroid/btc/core/btc_ble_storage.c index ea1c802cd4..228fcb4ebb 100644 --- a/components/bt/host/bluedroid/btc/core/btc_ble_storage.c +++ b/components/bt/host/bluedroid/btc/core/btc_ble_storage.c @@ -79,8 +79,10 @@ static void _btc_storage_save(void) BTA_DmRemoveDevice(bd_addr.address, BT_TRANSPORT_LE); BTA_DmRemoveDevice(bd_addr.address, BT_TRANSPORT_BR_EDR); //delete config info - if(btc_config_remove_section(need_remove_section)) { - BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section); + if (btc_config_remove_section(need_remove_section)) { + // The need_remove_section has been freed + BTIF_TRACE_WARNING("Exceeded the maximum number of bonded devices. Deleting the last 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]); } } }