diff --git a/libraries/AC_Avoidance/AP_OADatabase.cpp b/libraries/AC_Avoidance/AP_OADatabase.cpp index e569336ec5..1cf518a42a 100644 --- a/libraries/AC_Avoidance/AP_OADatabase.cpp +++ b/libraries/AC_Avoidance/AP_OADatabase.cpp @@ -186,6 +186,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()