]> granicus.if.org Git - esp-idf/commitdiff
Squash the two submissions of previous.
authorYulong <huangyulong@espressif.com>
Mon, 23 Oct 2017 03:07:03 +0000 (23:07 -0400)
committerYulong <huangyulong@espressif.com>
Mon, 23 Oct 2017 09:24:02 +0000 (05:24 -0400)
component/bt: The application layer does not allocate memory correctly causing the btc layer pointer to cross the border.

bt/examples: Change the gattc_multi_connect.c incorrect memory apply method.

examples/bluetooth/gatt_client/main/gattc_demo.c
examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c
examples/bluetooth/gattc_multi_connect/main/gattc_multi_connect.c

index 24fe67ac04736e54558e88c45c5cb91ec915975b..14290c2d870086b5d78b6b83d2e755b8f2c94ae8 100644 (file)
@@ -170,7 +170,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
             }
 
             if (count > 0){
-                char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result) * count);
+                char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
                 if (!char_elem_result){
                     ESP_LOGE(GATTC_TAG, "gattc no mem");
                 }else{
@@ -216,7 +216,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
                 ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
             }
             if (count > 0){
-                descr_elem_result = malloc(sizeof(descr_elem_result) * count);
+                descr_elem_result = malloc(sizeof(esp_gattc_descr_elem_t) * count);
                 if (!descr_elem_result){
                     ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
                 }else{
index cf9ec505a163a6719b08728be78d7592f98f46e5..6ae360e654a1db3f180380e70e2a65fe80172148 100644 (file)
@@ -191,7 +191,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
                 ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error, %d", __LINE__);
             }
             if (count > 0){
-                char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result) * count);
+                char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
                 if (!char_elem_result){
                     ESP_LOGE(GATTC_TAG, "gattc no mem");
                 }else{
@@ -245,7 +245,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
                 ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error, %d", __LINE__);
             }
             if (count > 0){
-                descr_elem_result = malloc(sizeof(descr_elem_result) * count);
+                descr_elem_result = malloc(sizeof(esp_gattc_descr_elem_t) * count);
                 if (!descr_elem_result){
                     ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
                 }else{
index 61c29edc0e564577e4e4aaeb8238504b52b7e35f..b734d7fa45648ba3ec291303c0dd758c9ec6455d 100644 (file)
@@ -209,7 +209,7 @@ static void gattc_profile_a_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
                 ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
             }
             if (count > 0) {
-                char_elem_result_a = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result_a) * count);
+                char_elem_result_a = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
                 if (!char_elem_result_a){
                     ESP_LOGE(GATTC_TAG, "gattc no mem");
                 }else {
@@ -255,7 +255,7 @@ static void gattc_profile_a_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
             ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
         }
         if (count > 0){
-            descr_elem_result_a = malloc(sizeof(descr_elem_result_a) * count);
+            descr_elem_result_a = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count);
             if (!descr_elem_result_a){
                 ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
             }else{
@@ -410,7 +410,7 @@ static void gattc_profile_b_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
             }
 
             if (count > 0){
-                char_elem_result_b = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result_b) * count);
+                char_elem_result_b = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
                 if (!char_elem_result_b){
                     ESP_LOGE(GATTC_TAG, "gattc no mem");
                 }else{
@@ -457,7 +457,7 @@ static void gattc_profile_b_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
             ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
         }
         if (count > 0){
-            descr_elem_result_b = malloc(sizeof(descr_elem_result_b) * count);
+            descr_elem_result_b = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count);
             if (!descr_elem_result_b){
                 ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
             }else{
@@ -609,7 +609,7 @@ static void gattc_profile_c_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
             }
 
             if (count > 0){
-                char_elem_result_c = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result_c) * count);
+                char_elem_result_c = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
                 if (!char_elem_result_c){
                     ESP_LOGE(GATTC_TAG, "gattc no mem");
                 }else{
@@ -655,7 +655,7 @@ static void gattc_profile_c_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
             ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
         }
         if (count > 0){
-            descr_elem_result_c = malloc(sizeof(descr_elem_result_c) * count);
+            descr_elem_result_c = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count);
             if (!descr_elem_result_c){
                 ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
             }else{