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

mavlink: fixed nullptr dereferencing #10063

Merged
merged 1 commit into from
Jul 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/modules/mavlink/mavlink_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,20 @@ Mavlink::forward_message(const mavlink_message_t *msg, Mavlink *self)
if (inst != self) {
const mavlink_msg_entry_t *meta = mavlink_get_msg_entry(msg->msgid);

// Extract target system and target component if set
int target_system_id = (meta->target_system_ofs != 0) ? ((uint8_t *)msg)[meta->target_system_ofs] : 0;
int target_component_id = (meta->target_component_ofs != 0) ? ((uint8_t *)msg)[meta->target_component_ofs] : 233;
int target_system_id = 0;
int target_component_id = 233;
Copy link
Member

Choose a reason for hiding this comment

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

233?


// might be nullptr if message is unknown
if (meta) {
// Extract target system and target component if set
if (meta->target_system_ofs != 0) {
target_system_id = ((uint8_t *)msg)[meta->target_system_ofs];
}

if (meta->target_component_ofs != 0) {
target_component_id = ((uint8_t *)msg)[meta->target_component_ofs];
}
}

// Broadcast or addressing this system and not trying to talk
// to the autopilot component -> pass on to other components
Expand Down