From c0b0ae44d53efe1f03e305429954c59cdff5f346 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 8 Feb 2023 19:17:35 +1100 Subject: [PATCH] Copter: don't use uninitialised stack data when determining ekf_over_threshold --- ArduCopter/ekf_check.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ArduCopter/ekf_check.cpp b/ArduCopter/ekf_check.cpp index 0b5fde50af..2ef99302f0 100644 --- a/ArduCopter/ekf_check.cpp +++ b/ArduCopter/ekf_check.cpp @@ -121,7 +121,9 @@ bool Copter::ekf_over_threshold() // use EKF to get variance float position_variance, vel_variance, height_variance, tas_variance; Vector3f mag_variance; - ahrs.get_variances(vel_variance, position_variance, height_variance, mag_variance, tas_variance); + if (!ahrs.get_variances(vel_variance, position_variance, height_variance, mag_variance, tas_variance)) { + return false; + } const float mag_max = fmaxf(fmaxf(mag_variance.x,mag_variance.y),mag_variance.z);