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 the potential application crash issues #426

Merged
merged 4 commits into from Dec 19, 2017

Conversation

gaoethan
Copy link
Contributor

@gaoethan gaoethan commented Dec 18, 2017

get_topic_name and rcl_service_get_service_name may return NULL

Signed-off-by: Ethan Gao ethan.gao@linux.intel.com

auto intra_process_topic_name = std::string(this->get_topic_name()) + "/_intra";
const char * topic_name = this->get_topic_name();
if (topic_name) {
auto intra_process_topic_name = std::string(topic_name) + "/_intra";
Copy link
Member

Choose a reason for hiding this comment

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

Have you tried to compile the patch locally (and ran the tests)? It look to me that the variable has a local scope and therefore isn't available below where it is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

badly, it becomes a local scope within if{}, and I changed it. Now all have passed the build and tests, thanks !

intra_process_topic_name = std::string(topic_name) + "/_intra";
} else {
throw std::runtime_error("Get a invalid null topic name");
}
Copy link
Member

Choose a reason for hiding this comment

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

Please use a similar structure here as above. Check for !topic_name and conditionally throw, Then the else case becomes obsolete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense, changed 😄

@dirk-thomas
Copy link
Member

I modified the error message slight. Looks good to me now:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@dirk-thomas dirk-thomas added the in review Waiting for review (Kanban column) label Dec 19, 2017
gaoethan and others added 3 commits December 19, 2017 23:50
Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
@clalancette
Copy link
Contributor

Builds are all green, @dirk-thomas thinks it is OK, looks OK to me. Merging.

@clalancette clalancette merged commit 199a269 into ros2:master Dec 19, 2017
@clalancette clalancette removed the in review Waiting for review (Kanban column) label Dec 19, 2017
@gaoethan gaoethan deleted the nullderef branch December 20, 2017 01:16
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
This way we avoid tripping a Fast-CDR check for a 0 or 1
in the bool field.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
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

3 participants