AP_HAL_ChibiOS: check nullptr 'name' variable
- Check nullptr before using the 'name' variable assigned from malloc()
This commit is contained in:
parent
20d04fa823
commit
e3f76591fc
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user