From e184e78e524c48af687f6a2e83836e59e2e04258 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 2 Jan 2023 08:33:22 +1100 Subject: [PATCH] AC_Avoidance: check for alloc failure of ObjectBuffer --- libraries/AC_Avoidance/AP_OADatabase.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/AC_Avoidance/AP_OADatabase.cpp b/libraries/AC_Avoidance/AP_OADatabase.cpp index c9e211ba1e..37fb5d7b0e 100644 --- a/libraries/AC_Avoidance/AP_OADatabase.cpp +++ b/libraries/AC_Avoidance/AP_OADatabase.cpp @@ -187,6 +187,11 @@ void AP_OADatabase::init_queue() } _queue.items = new ObjectBuffer(_queue.size); + if (_queue.items != nullptr && _queue.items->get_size() == 0) { + // allocation failed + delete _queue.items; + _queue.items = nullptr; + } } void AP_OADatabase::init_database()