]> granicus.if.org Git - esp-idf/commitdiff
compoent/bt: Fix the bug when do the BLE pressure test will lead to memory leak will...
authoryulong <huangyulong@espressif.com>
Tue, 28 Nov 2017 07:43:33 +0000 (15:43 +0800)
committeryulong <huangyulong@espressif.com>
Tue, 28 Nov 2017 07:43:33 +0000 (15:43 +0800)
components/bt/bluedroid/bta/gatt/bta_gattc_utils.c
components/bt/bluedroid/stack/gatt/gatt_utils.c

index b5409b40b3bc5a5bec07be994735b43d756f27db..676ed851ac0abe63d521091d32a9e45549642ae8 100644 (file)
@@ -232,8 +232,9 @@ tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bd
             bdcpy(p_clcb->bda, remote_bda);
 
             p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if);
-            p_clcb->p_cmd_list = list_new(osi_free_func);
-
+            if (p_clcb->p_cmd_list == NULL) {
+                p_clcb->p_cmd_list = list_new(osi_free_func);
+            }
             if ((p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda)) == NULL) {
                 p_clcb->p_srcb      = bta_gattc_srcb_alloc(remote_bda);
             }
@@ -310,6 +311,7 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
         p_clcb->p_q_cmd = NULL;
         // don't forget to clear the command queue before dealloc the clcb.
         list_clear(p_clcb->p_cmd_list);
+        osi_free((void *)p_clcb->p_cmd_list);
         //osi_free_and_reset((void **)&p_clcb->p_q_cmd);
         memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB));
     } else {
index 9d2ae16f7c0f441e15cd162cb812321b1a6b6a36..5b0db44e9e765df02d9ff13d345fc875638ebedc 100644 (file)
@@ -861,7 +861,7 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
     list_t *list = fixed_queue_get_list(gatt_cb.srv_chg_clt_q);
     for (const list_node_t *node = list_begin(list); node != list_end(list);
          node = list_next(node)) {
-        tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)list_node(node);
+        p_buf = (tGATTS_SRV_CHG *)list_node(node);
         if (!memcmp( bda, p_buf->bda, BD_ADDR_LEN)) {
             GATT_TRACE_DEBUG("bda is in the srv chg clt list");
             break;