]> granicus.if.org Git - esp-idf/commitdiff
component/bt: Avoid PLC to use unallocated memory
authorbaohongde <baohongde@espressif.com>
Fri, 26 Jul 2019 06:39:50 +0000 (14:39 +0800)
committerbaohongde <baohongde@espressif.com>
Fri, 26 Jul 2019 06:39:50 +0000 (14:39 +0800)
Closes https://github.com/espressif/esp-idf/pull/3799

components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c
components/bt/host/bluedroid/stack/include/stack/btm_api.h

index b8b2ea40c776c6490508b42c7e14b709da009f08..99b928030446ea991bec3deeb6bd042d361c7616 100644 (file)
@@ -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;
 }
 
 /*******************************************************************************
index b51ecb00694f5ff3a409da0a86c0b4a9f4a1735c..641dd93f527e9703a5a6977925c88f7e6a99d4dc 100644 (file)
@@ -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;
 
 /*******************