From 3faeb6644fa7de7b0c4fd6836e45c42eb2d58b5d Mon Sep 17 00:00:00 2001 From: Maxim Reznik Date: Thu, 9 May 2024 13:07:45 +0300 Subject: [PATCH] Initialize sample buffer pointer with nullptr to avoid memory corruption on deallocating uninitialized value in `CompassCalibrator.cpp`:384: ```c if (_sample_buffer != nullptr) { free(_sample_buffer); ``` --- libraries/AP_Compass/CompassCalibrator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Compass/CompassCalibrator.cpp b/libraries/AP_Compass/CompassCalibrator.cpp index 57a374987c571..5e948be077f23 100644 --- a/libraries/AP_Compass/CompassCalibrator.cpp +++ b/libraries/AP_Compass/CompassCalibrator.cpp @@ -79,7 +79,8 @@ extern const AP_HAL::HAL& hal; ///////////////////// PUBLIC INTERFACE ///////////////////// //////////////////////////////////////////////////////////// -CompassCalibrator::CompassCalibrator() +CompassCalibrator::CompassCalibrator() : + _sample_buffer(nullptr) { set_status(Status::NOT_STARTED); }