Skip to content

Commit

Permalink
AP_HAL_ChibiOS: check nullptr 'name' variable
Browse files Browse the repository at this point in the history
- Check nullptr before using the  'name' variable assigned from malloc()
  • Loading branch information
RuffaloLavoisier authored and peterbarker committed Sep 17, 2024
1 parent 20d04fa commit e3f7659
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libraries/AP_HAL_ChibiOS/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e3f7659

Please sign in to comment.