diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp index 79370e17c0..26e708fb73 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp @@ -397,6 +397,7 @@ AP_InertialSensor_MPU6000::AP_InertialSensor_MPU6000(AP_InertialSensor &imu, AP_ AP_InertialSensor_MPU6000::~AP_InertialSensor_MPU6000() { delete _bus; + delete _samples; } /* Detect the sensor on SPI bus. It must have a corresponding device on diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.h b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.h index e5d7392ef9..bb134610cd 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.h @@ -111,7 +111,7 @@ private: #endif volatile uint16_t _sum_count; bool _fifo_mode; - uint8_t *_samples; + uint8_t *_samples = nullptr; }; class AP_MPU6000_BusDriver_SPI : public AP_MPU6000_BusDriver