From fb95332a229d9c0518df166cbe8a7b5e2cf413c2 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Thu, 26 Sep 2024 18:54:43 +0800 Subject: [PATCH] fix(i2c_master): Fix the memory leak in the async transaction --- components/esp_driver_i2c/i2c_master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_driver_i2c/i2c_master.c b/components/esp_driver_i2c/i2c_master.c index 09b0b17706..ad18d2806d 100644 --- a/components/esp_driver_i2c/i2c_master.c +++ b/components/esp_driver_i2c/i2c_master.c @@ -845,7 +845,7 @@ static esp_err_t s_i2c_asynchronous_transaction(i2c_master_dev_handle_t i2c_dev, // Clear unused memory uint8_t unused_dim = I2C_STATIC_OPERATION_ARRAY_MAX - ops_dim; if (unused_dim != 0) { - memset(&i2c_master->i2c_async_ops[i2c_master->ops_prepare_idx] + sizeof(i2c_operation_t) * ops_dim, 0, sizeof(i2c_operation_t) * unused_dim); + memset(&i2c_master->i2c_async_ops[i2c_master->ops_prepare_idx][ops_dim], 0, sizeof(i2c_operation_t) * unused_dim); } // Record current operation and feed to transaction queue. ops_current = &i2c_master->i2c_async_ops[i2c_master->ops_prepare_idx][0];