diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index 44631343c4..9ad050645e 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -177,6 +177,11 @@ VtolAttitudeControl::~VtolAttitudeControl() } while (_control_task != -1); } + // free memory used by instances of base class VtolType + if (_vtol_type != nullptr) { + delete _vtol_type; + } + VTOL_att_control::g_control = nullptr; } diff --git a/src/modules/vtol_att_control/vtol_att_control_main.h b/src/modules/vtol_att_control/vtol_att_control_main.h index 1f0917f12f..e268a92b20 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.h +++ b/src/modules/vtol_att_control/vtol_att_control_main.h @@ -218,10 +218,10 @@ private: int _transition_command; bool _abort_front_transition; - VtolType *_vtol_type; // base class for different vtol types - Tiltrotor *_tiltrotor; // tailsitter vtol type - Tailsitter *_tailsitter; // tiltrotor vtol type - Standard *_standard; // standard vtol type + VtolType *_vtol_type = nullptr; // base class for different vtol types + Tiltrotor *_tiltrotor = nullptr; // tailsitter vtol type + Tailsitter *_tailsitter = nullptr; // tiltrotor vtol type + Standard *_standard = nullptr; // standard vtol type //*****************Member functions***********************************************************************