From 8c192bf42c791993647f48b6f08f9698d768616b Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 9 Feb 2023 10:44:35 +0100 Subject: [PATCH] Wire: nullify pointers on end() --- libraries/Wire/Wire.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index a48b3ff94..b90dcc1a5 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -45,6 +45,7 @@ void arduino::MbedI2C::begin(uint8_t slaveAddr) { void arduino::MbedI2C::end() { if (master != NULL) { delete master; + master = NULL; } #ifdef DEVICE_I2CSLAVE if (slave != NULL) { @@ -52,6 +53,7 @@ void arduino::MbedI2C::end() { slave_th->free_stack(); delete slave_th; delete slave; + slave = NULL; } #endif }