From 8c20a9b71692255073e79e40850d757cdafa8b99 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 3 May 2024 08:08:40 +0200 Subject: [PATCH] [SceneUtility] Initialize pointer to nullptr (#4712) --- .../component/sceneutility/MessageHandlerComponent.cpp | 8 +++++--- .../sofa/component/sceneutility/MessageHandlerComponent.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp index 56c54d9da54..90ac4caf386 100644 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp +++ b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp @@ -115,9 +115,11 @@ FileMessageHandlerComponent::FileMessageHandlerComponent() : FileMessageHandlerComponent::~FileMessageHandlerComponent() { - MessageDispatcher::rmHandler(m_handler) ; - - delete m_handler ; + if (m_handler) + { + MessageDispatcher::rmHandler(m_handler) ; + delete m_handler ; + } } void FileMessageHandlerComponent::parse ( core::objectmodel::BaseObjectDescription* arg ) diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h index cd2187d2aa9..b2d3f946f39 100644 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h +++ b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h @@ -77,7 +77,7 @@ class SOFA_COMPONENT_SCENEUTILITY_API FileMessageHandlerComponent : public core: void parse ( core::objectmodel::BaseObjectDescription* arg ) override; Data d_filename ; ///< Name of the file into which the message will be saved in. - helper::logging::MessageHandler* m_handler ; + helper::logging::MessageHandler* m_handler { nullptr }; bool m_isValid ;