From 478bc39aa76506784f49eadd6ce0c92fe6789d90 Mon Sep 17 00:00:00 2001 From: EiriniP Date: Fri, 7 Aug 2026 10:39:37 +0300 Subject: [PATCH] hal_esp32_i2c: fix dangling pointer bug --- lib/hal/hal_esp32_i2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/hal/hal_esp32_i2c.c b/lib/hal/hal_esp32_i2c.c index 3057d1ec..f9a1c5b4 100644 --- a/lib/hal/hal_esp32_i2c.c +++ b/lib/hal/hal_esp32_i2c.c @@ -250,6 +250,7 @@ ATCA_STATUS hal_i2c_send(ATCAIface iface, uint8_t word_address, uint8_t *txdata, } (void)i2c_master_bus_rm_device(i2c_hal_data[bus].dev_handle); + i2c_hal_data[bus].dev_handle = NULL; #endif @@ -317,6 +318,7 @@ ATCA_STATUS hal_i2c_receive(ATCAIface iface, uint8_t address, uint8_t *rxdata, u } (void)i2c_master_bus_rm_device(i2c_hal_data[bus].dev_handle); + i2c_hal_data[bus].dev_handle = NULL; #endif @@ -341,6 +343,7 @@ ATCA_STATUS hal_i2c_release(void *hal_data) if (hal->dev_handle) { rc = i2c_master_bus_rm_device(hal->dev_handle); + hal->dev_handle = NULL; } if (hal && --(hal->ref_ct) <= 0)