Skip to content

Commit 6de22b6

Browse files
committed
Add delete/nullptr check to begin (dtor not called)
1 parent 39a15fd commit 6de22b6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_MLX90632D.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class WipperSnapper_I2C_Driver_MLX90632D : public WipperSnapper_I2C_Driver {
6565
*/
6666
/*******************************************************************************/
6767
bool begin() {
68+
if (_mlx90632) {
69+
delete _mlx90632;
70+
_mlx90632 = nullptr;
71+
}
6872
_mlx90632 = new Adafruit_MLX90632();
6973
// attempt to initialize MLX90632
7074
if (!_mlx90632->begin(_sensorAddress, _i2c)) return false;

0 commit comments

Comments
 (0)