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 3855c37 commit 7a520ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ecal/core/src/readwrite/ecal_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,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)
{
SSubEventCallbackData data;
data.type = sub_event_connected;
Expand All @@ -671,7 +671,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 @@ -785,7 +785,7 @@ namespace eCAL
{
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
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,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)
{
SPubEventCallbackData data;
data.type = pub_event_connected;
Expand All @@ -997,7 +997,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 7a520ed

Please sign in to comment.