Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out-of-range exception #166

Closed
wants to merge 1 commit into from

Conversation

chenx-dust
Copy link

When using relative topic name to subscribe, and the name is shorter than namespace, it will lead to out-of-range exception.
This PR is to fix it.

Backport to older version needed!!!

std::string param_base_name = base_topic.substr(ns_len);
std::replace(param_base_name.begin(), param_base_name.end(), '/', '.');
if (base_topic.length() >= ns_len) {
std::string param_base_name = base_topic.substr(ns_len);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you already try this patch ? There is a compilation error

14:50:25 /tmp/ws/src/image_transport_plugins/zstd_image_transport/src/zstd_publisher.cpp: In member function ‘virtual void zstd_image_transport::ZstdPublisher::advertiseImpl(rclcpp::Node*, const string&, rmw_qos_profile_t, rclcpp::PublisherOptions)’:
14:50:25 /tmp/ws/src/image_transport_plugins/zstd_image_transport/src/zstd_publisher.cpp:93:22: error: ‘param_base_name’ was not declared in this scope
14:50:25    93 |     declareParameter(param_base_name, pd);

param_base_name is defined inside the if scope but this variable is used in the outer scope

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it, sorry for that. I found this issue resulting in exception in my code, and I adopted a workaround, and then I forgot to compile and test this patch. I'll fix it soon.

@ahcorde
Copy link
Contributor

ahcorde commented Jun 14, 2024

friendly ping @chenx-dust

@chenx-dust
Copy link
Author

friendly ping @chenx-dust

Sorry. I'm quite busy recently. If possible, please solve it for me, thank you. 🙏

I'll close this PR until I'm available to resolve it. Sorry for any inconvenience.

@chenx-dust chenx-dust closed this Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants