Skip to content

Fix the potential application crash issues#426

Merged
clalancette merged 4 commits intoros2:masterfrom
gaoethan:nullderef
Dec 19, 2017
Merged

Fix the potential application crash issues#426
clalancette merged 4 commits intoros2:masterfrom
gaoethan:nullderef

Conversation

@gaoethan
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants