GCS_MAVLink: serial control: avoid nullptr dererences

This commit is contained in:
Peter Barker 2018-03-31 16:26:05 +11:00 committed by Francisco Ferreira
parent b864cd6ae6
commit 1f862e8192
1 changed files with 11 additions and 1 deletions

View File

@ -61,12 +61,22 @@ void GCS_MAVLINK::handle_serial_control(const mavlink_message_t *msg)
break;
case SERIAL_CONTROL_DEV_SHELL:
stream = hal.util->get_shell_stream();
if (stream == nullptr) {
return;
}
break;
default:
// not supported yet
return;
}
if (stream == nullptr) {
// this is probably very bad
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
AP_HAL::panic("stream is nullptr");
#endif
return;
}
if (exclusive && port != nullptr) {
// force flow control off for exclusive access. This protocol
// is used to talk to bootloaders which may not have flow