From c2f9a0ad875912a5ed86749f97f543a1a4e1e4a5 Mon Sep 17 00:00:00 2001 From: liqigan Date: Tue, 12 Jul 2022 15:57:23 +0800 Subject: [PATCH] fix memory leak in esp_bt_hidh_dev_report_write and esp_bt_hidh_dev_set_report in bt_hidh.c Closes https://github.com/espressif/esp-idf/issues/9323 --- components/esp_hid/src/bt_hidh.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/esp_hid/src/bt_hidh.c b/components/esp_hid/src/bt_hidh.c index 6c3ea158d5..19ca5034a0 100644 --- a/components/esp_hid/src/bt_hidh.c +++ b/components/esp_hid/src/bt_hidh.c @@ -803,8 +803,13 @@ static esp_err_t esp_bt_hidh_dev_report_write(esp_hidh_dev_t *dev, size_t map_in data = p_data; len = len + 1; } + ret = esp_bt_hid_host_send_data(dev->bda, data, len); + if (p_data) { + free(p_data); + } } while (0); + return ret; } @@ -845,11 +850,17 @@ static esp_err_t esp_bt_hidh_dev_set_report(esp_hidh_dev_t *dev, size_t map_inde data = p_data; len = len + 1; } + ret = esp_bt_hid_host_set_report(dev->bda, report_type, data, len); + if (p_data) { + free(p_data); + } + if (ret == ESP_OK) { set_trans(dev, ESP_HID_TRANS_SET_REPORT); } } while (0); + return ret; }