Skip to content

Commit

Permalink
[Core] Check validity of event callbacks before actually calling them. (
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller authored and FlorianReimold committed Jan 26, 2024
1 parent b424699 commit 480d104
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions ecal/core/src/readwrite/ecal_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(sub_event_connected);
if (iter != m_event_callback_map.end())
if (iter != m_event_callback_map.end() && iter->second)
{
data.type = sub_event_connected;
data.tid = tid_;
Expand All @@ -745,7 +745,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(sub_event_update_connection);
if (iter != m_event_callback_map.end())
if (iter != m_event_callback_map.end() && iter->second)
{
data.type = sub_event_update_connection;
data.tid = tid_;
Expand All @@ -767,7 +767,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(sub_event_disconnected);
if (iter != m_event_callback_map.end())
if (iter != m_event_callback_map.end() && iter->second)
{
SSubEventCallbackData data;
data.type = sub_event_disconnected;
Expand Down Expand Up @@ -958,7 +958,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(sub_event_timeout);
if(iter != m_event_callback_map.end())
if(iter != m_event_callback_map.end() && iter->second)
{
SSubEventCallbackData data;
data.type = sub_event_timeout;
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(pub_event_connected);
if (iter != m_event_callback_map.end())
if (iter != m_event_callback_map.end() && iter->second)
{
data.type = pub_event_connected;
(iter->second)(m_topic_name.c_str(), &data);
Expand All @@ -1019,7 +1019,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(pub_event_update_connection);
if (iter != m_event_callback_map.end())
if (iter != m_event_callback_map.end() && iter->second)
{
data.type = pub_event_update_connection;
data.tid = tid_;
Expand All @@ -1042,7 +1042,7 @@ namespace eCAL
{
const std::lock_guard<std::mutex> lock(m_event_callback_map_sync);
auto iter = m_event_callback_map.find(pub_event_disconnected);
if (iter != m_event_callback_map.end())
if (iter != m_event_callback_map.end() && iter->second)
{
SPubEventCallbackData data;
data.type = pub_event_disconnected;
Expand Down

0 comments on commit 480d104

Please sign in to comment.