From 1f862e819213a1f1ea96845909f89d38daf01877 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 31 Mar 2018 16:26:05 +1100 Subject: [PATCH] GCS_MAVLink: serial control: avoid nullptr dererences --- libraries/GCS_MAVLink/GCS_serial_control.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS_serial_control.cpp b/libraries/GCS_MAVLink/GCS_serial_control.cpp index 425b94f56b..117641c690 100644 --- a/libraries/GCS_MAVLink/GCS_serial_control.cpp +++ b/libraries/GCS_MAVLink/GCS_serial_control.cpp @@ -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