fix(ble/bluedroid): Use calloc in gatt_server example

(cherry picked from commit e26b60090d)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
Zhang Hai Peng
2025-12-03 11:54:26 +08:00
parent 07ce6a9fc8
commit e2242b02ef
@@ -282,7 +282,8 @@ void example_write_event_env(esp_gatt_if_t gatts_if, prepare_type_env_t *prepare
} }
} }
esp_gatt_rsp_t *gatt_rsp = (esp_gatt_rsp_t *)malloc(sizeof(esp_gatt_rsp_t)); // Security fix: Use calloc to ensure memory is zero-initialized
esp_gatt_rsp_t *gatt_rsp = (esp_gatt_rsp_t *)calloc(1, sizeof(esp_gatt_rsp_t));
if (gatt_rsp) { if (gatt_rsp) {
gatt_rsp->attr_value.len = param->write.len; gatt_rsp->attr_value.len = param->write.len;
gatt_rsp->attr_value.handle = param->write.handle; gatt_rsp->attr_value.handle = param->write.handle;