AP_HAL_ChibiOS: check nullptr 'name' variable

- Check nullptr before using the  'name' variable assigned from malloc()
This commit is contained in:
Ruffalo Lavoisier 2024-09-17 12:18:37 +09:00 committed by Peter Barker
parent 20d04fa823
commit e3f76591fc

View File

@ -111,6 +111,9 @@ AP_HAL::Device::PeriodicHandle DeviceBus::register_periodic_callback(uint32_t pe
// setup a name for the thread
const uint8_t name_len = 7;
char *name = (char *)malloc(name_len);
if (name == nullptr){
return nullptr;
}
switch (hal_device->bus_type()) {
case AP_HAL::Device::BUS_TYPE_I2C:
snprintf(name, name_len, "I2C%u",