forked from Archive/PX4-Autopilot
bmp388: fix double free in case the driver probing fails
'interface' is freed in BMP388's destructor.
This commit is contained in:
parent
c5a0d9077b
commit
0c6d558c50
|
@ -103,10 +103,15 @@ static bool start_bus(bmp388_bus_option &bus)
|
|||
|
||||
BMP388 *dev = new BMP388(interface);
|
||||
|
||||
if (dev == nullptr || (dev->init() != PX4_OK)) {
|
||||
if (dev == nullptr) {
|
||||
PX4_ERR("alloc failed");
|
||||
delete interface;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dev->init() != PX4_OK) {
|
||||
PX4_ERR("driver start failed");
|
||||
delete dev;
|
||||
delete interface;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue