From 82ae3fe63528e475b8547a72853a17fa47c08bd7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 14 Nov 2020 14:09:24 +1100 Subject: [PATCH] AP_NavEKF3: fixed memory corruption on push before init this fixes a bug that happens with VISION_SPEED_ESTIMATE from a companion computer, which may come in before the EKF buffers are allocated. That causes a push to an uninitialised ringbuffer which triggers memory corruption found using the new memory guard system --- libraries/AP_NavEKF3/AP_NavEKF3_Buffer.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/AP_NavEKF3/AP_NavEKF3_Buffer.h b/libraries/AP_NavEKF3/AP_NavEKF3_Buffer.h index 327e361935..6672fe4a88 100644 --- a/libraries/AP_NavEKF3/AP_NavEKF3_Buffer.h +++ b/libraries/AP_NavEKF3/AP_NavEKF3_Buffer.h @@ -85,6 +85,9 @@ public: */ inline void push(element_type element) { + if (buffer == nullptr) { + return; + } // Advance head to next available index _head = (_head+1)%_size; // New data is written at the head