AP_CANManager: check for alloc failure of ObjectBuffer

This commit is contained in:
Andrew Tridgell 2023-01-02 08:33:22 +11:00
parent e184e78e52
commit 6bff28d5d5
1 changed files with 3 additions and 1 deletions

View File

@ -427,11 +427,13 @@ void AP_CANManager::handle_can_frame(const mavlink_message_t &msg)
while (frame_buffer == nullptr && buffer_size > 0) {
// we'd like 20 frames, but will live with less
frame_buffer = new ObjectBuffer<BufferFrame>(buffer_size);
if (frame_buffer != nullptr) {
if (frame_buffer != nullptr && frame_buffer->get_size() != 0) {
// register a callback for when frames can't be sent immediately
hal.scheduler->register_io_process(FUNCTOR_BIND_MEMBER(&AP_CANManager::process_frame_buffer, void));
break;
}
delete frame_buffer;
frame_buffer = nullptr;
buffer_size /= 2;
}
if (frame_buffer == nullptr) {