From 5385f25868b4b1ef6577516101fb8bb033f7dfc8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Nov 2020 08:40:45 +1100 Subject: [PATCH] AP_RSSI: handle init ordering with MSP this fixes a nullptr dereference on startup when MSP asks for RSSI data before the RSSI library is initialised Fixes #15824 --- libraries/AP_RSSI/AP_RSSI.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/AP_RSSI/AP_RSSI.cpp b/libraries/AP_RSSI/AP_RSSI.cpp index 878527366c..e834fa986d 100644 --- a/libraries/AP_RSSI/AP_RSSI.cpp +++ b/libraries/AP_RSSI/AP_RSSI.cpp @@ -167,6 +167,9 @@ uint8_t AP_RSSI::read_receiver_rssi_uint8() // read the RSSI value from an analog pin - returns float in range 0.0 to 1.0 float AP_RSSI::read_pin_rssi() { + if (!rssi_analog_source) { + return 0; + } rssi_analog_source->set_pin(rssi_analog_pin); float current_analog_voltage = rssi_analog_source->voltage_average();