Skip to content

Commit

Permalink
fix: check the context validity before accessing the session (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanYuYuan authored Jan 9, 2025
1 parent e855fa7 commit 660b1b0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ rmw_create_publisher(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (context_impl->is_shutdown()) {
RMW_SET_ERROR_MSG("context_impl is shutdown");
return nullptr;
}
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
Expand Down Expand Up @@ -936,6 +940,10 @@ rmw_create_subscription(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (context_impl->is_shutdown()) {
RMW_SET_ERROR_MSG("context_impl is shutdown");
return nullptr;
}
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
Expand Down Expand Up @@ -1439,6 +1447,10 @@ rmw_create_client(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (context_impl->is_shutdown()) {
RMW_SET_ERROR_MSG("context_impl is shutdown");
return nullptr;
}
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
Expand Down Expand Up @@ -1701,6 +1713,10 @@ rmw_create_service(
context_impl,
"unable to get rmw_context_impl_s",
return nullptr);
if (context_impl->is_shutdown()) {
RMW_SET_ERROR_MSG("context_impl is shutdown");
return nullptr;
}
if (!context_impl->session_is_valid()) {
RMW_SET_ERROR_MSG("zenoh session is invalid");
return nullptr;
Expand Down

0 comments on commit 660b1b0

Please sign in to comment.