From 806f58f3f6fa0606f24e3f335c7f797b7ad80a3d Mon Sep 17 00:00:00 2001 From: Antonio Vanegas Date: Thu, 13 Jan 2022 01:05:03 +0100 Subject: [PATCH] Fix issue #67 printSensorDetails() issue (#68) * Remove delete objects instructions when the constructor is not empty * removed comments because the test in the real device pass ok * added validation before delete objects * fix clang issue * fix clang issue * added missing validations for objects to delete * restored fix after tests over two boards: TTGO T7 and M5StickC --- Adafruit_BMP280.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Adafruit_BMP280.cpp b/Adafruit_BMP280.cpp index 3ffb707..0994325 100644 --- a/Adafruit_BMP280.cpp +++ b/Adafruit_BMP280.cpp @@ -37,8 +37,10 @@ Adafruit_BMP280::~Adafruit_BMP280(void) { delete spi_dev; if (i2c_dev) delete i2c_dev; - delete temp_sensor; - delete pressure_sensor; + if (temp_sensor == nullptr) + delete temp_sensor; + if (pressure_sensor == nullptr) + delete pressure_sensor; } /*!