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
…407)

(cherry picked from commit 660b1b0)

Co-authored-by: Yuyuan Yuan <az6980522@gmail.com>
  • Loading branch information
mergify[bot] and YuanYuYuan authored Jan 10, 2025
1 parent ba92286 commit 8bb41f5
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 @@ -388,6 +388,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 @@ -876,6 +880,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 @@ -1348,6 +1356,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 @@ -1596,6 +1608,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 8bb41f5

Please sign in to comment.