AP_HAL_Linux: check for alloc failure of ObjectBuffer

This commit is contained in:
Andrew Tridgell 2023-01-02 08:33:22 +11:00 committed by Randy Mackay
parent c602757c02
commit 54c3e7f74b
1 changed files with 5 additions and 0 deletions

View File

@ -171,6 +171,11 @@ void OpticalFlow_Onboard::init()
} }
_gyro_ring_buffer = new ObjectBuffer<GyroSample>(OPTICAL_FLOW_GYRO_BUFFER_LEN); _gyro_ring_buffer = new ObjectBuffer<GyroSample>(OPTICAL_FLOW_GYRO_BUFFER_LEN);
if (_gyro_ring_buffer != nullptr && _gyro_ring_buffer->get_size() == 0) {
// allocation failed
delete _gyro_ring_buffer;
_gyro_ring_buffer = nullptr;
}
_initialized = true; _initialized = true;
} }