uORB: fix hardfault in uORB calloc implementation

When running out-of-memory, the malloc returns NULL and the memset then tries to write to address 0 which results in a hardfault.
This commit is contained in:
Niklas Hauser 2023-09-07 20:22:58 +02:00 committed by GitHub
parent 35c1d5d9b1
commit ad1d72df6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -188,8 +188,11 @@ uORB::DeviceNode::write(cdev::file_t *filp, const char *buffer, size_t buflen)
if (nullptr == _data) {
const size_t data_size = _meta->o_size * _queue_size;
_data = (uint8_t *) px4_cache_aligned_alloc(data_size);
if (_data) {
memset(_data, 0, data_size);
}
}
unlock();