From 74978ac5778b3ea0b99697aacc32c4c9a513759e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 22 Dec 2022 17:31:50 +1100 Subject: [PATCH] GCS_MAVLink: add nullptr check in gcs_out_of_space_to_send If a library were to send on a channel for which we have not allocated a GCS_MAVLINK this could lead to a nullptr dereference. We do some odd things in uAvionix in terms of which channel to send on, so worth a check. --- libraries/GCS_MAVLink/GCS.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS.cpp b/libraries/GCS_MAVLink/GCS.cpp index 911b8732e2..70439fbfc8 100644 --- a/libraries/GCS_MAVLink/GCS.cpp +++ b/libraries/GCS_MAVLink/GCS.cpp @@ -355,7 +355,11 @@ bool GCS::out_of_time() const void gcs_out_of_space_to_send(mavlink_channel_t chan) { - gcs().chan(chan)->out_of_space_to_send(); + GCS_MAVLINK *link = gcs().chan(chan); + if (link == nullptr) { + return; + } + link->out_of_space_to_send(); } /*