fix esp hid crash when auth failed

This commit is contained in:
chenjianhua 2022-08-11 19:41:35 +08:00
parent 9269a536ac
commit d62b9505e3
2 changed files with 6 additions and 1 deletions

View File

@ -112,6 +112,8 @@ static void read_device_services(esp_gatt_if_t gattc_if, esp_hidh_dev_t *dev)
ESP_LOGE(TAG, "malloc report maps failed");
return;
}
/* read characteristic value may failed, so we should init report maps */
memset(dev->config.report_maps, 0, dev->config.report_maps_len * sizeof(esp_hid_raw_report_map_t));
for (uint16_t s = 0; s < dcount; s++) {
suuid = service_result[s].uuid.uuid.uuid16;

View File

@ -657,7 +657,10 @@ static void esp_hidh_dev_resources_free(esp_hidh_dev_t *dev)
free((void *)dev->config.manufacturer_name);
free((void *)dev->config.serial_number);
for (uint8_t d = 0; d < dev->config.report_maps_len; d++) {
free((void *)dev->config.report_maps[d].data);
/* data of report map maybe is NULL */
if (dev->config.report_maps[d].data) {
free((void *)dev->config.report_maps[d].data);
}
}
free((void *)dev->config.report_maps);
esp_hidh_dev_report_t *r;