From d1f774bc0a3c1de72b575ff980c7152725a510a3 Mon Sep 17 00:00:00 2001 From: baohongde Date: Fri, 26 Jul 2019 14:39:50 +0800 Subject: [PATCH] component/bt: Avoid PLC to use unallocated memory Closes https://github.com/espressif/esp-idf/pull/3799 --- .../btc/profile/std/hf_client/bta_hf_client_co.c | 10 ++++++++-- .../bt/host/bluedroid/stack/include/stack/btm_api.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c b/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c index b8b2ea40c7..99b9280304 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c @@ -73,8 +73,8 @@ static bta_hf_client_co_cb_t *bta_hf_client_co_cb_ptr; #define bta_hf_client_co_cb (*bta_hf_client_co_cb_ptr) #endif /* HFP_DYNAMIC_MEMORY == FALSE */ -static UINT8 hf_air_mode; -static UINT8 hf_inout_pkt_size; +static UINT8 hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; +static UINT8 hf_inout_pkt_size = 0; /******************************************************************************* ** @@ -223,6 +223,9 @@ void bta_hf_client_sco_co_open(UINT16 handle, UINT8 air_mode, UINT8 inout_pkt_si #if (HFP_DYNAMIC_MEMORY == TRUE) error_exit:; + hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; + hf_inout_pkt_size = 0; + if (bta_hf_client_co_cb_ptr) { osi_free(bta_hf_client_co_cb_ptr); bta_hf_client_co_cb_ptr = NULL; @@ -271,6 +274,9 @@ void bta_hf_client_sco_co_close(void) } else { // Nothing to do } + + hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; + hf_inout_pkt_size = 0; } /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_api.h index b51ecb0069..641dd93f52 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -983,6 +983,7 @@ typedef UINT16 tBTM_SCO_CODEC_TYPE; #define BTM_SCO_AIR_MODE_A_LAW 1 #define BTM_SCO_AIR_MODE_CVSD 2 #define BTM_SCO_AIR_MODE_TRANSPNT 3 +#define BTM_SCO_AIR_MODE_UNKNOWN 0xFF typedef UINT8 tBTM_SCO_AIR_MODE_TYPE; /******************* -- 2.40.0