Skip to content

Commit

Permalink
Initialize sample buffer pointer with nullptr
Browse files Browse the repository at this point in the history
to avoid memory corruption on deallocating uninitialized value in `CompassCalibrator.cpp`:384:

```c
if (_sample_buffer != nullptr) {
    free(_sample_buffer);
```
  • Loading branch information
reznikmm authored May 9, 2024
1 parent 4320063 commit 3faeb66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/AP_Compass/CompassCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ extern const AP_HAL::HAL& hal;
///////////////////// PUBLIC INTERFACE /////////////////////
////////////////////////////////////////////////////////////

CompassCalibrator::CompassCalibrator()
CompassCalibrator::CompassCalibrator() :
_sample_buffer(nullptr)
{
set_status(Status::NOT_STARTED);
}
Expand Down

0 comments on commit 3faeb66

Please sign in to comment.