mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
srf02: fix resource leak (unclosed fd)
This commit is contained in:
parent
ab94bf1d60
commit
5cc450c7cb
@ -700,7 +700,7 @@ void info();
|
||||
void
|
||||
start(uint8_t rotation)
|
||||
{
|
||||
int fd;
|
||||
int fd = -1;
|
||||
|
||||
if (g_dev != nullptr) {
|
||||
errx(1, "already started");
|
||||
@ -728,10 +728,15 @@ start(uint8_t rotation)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
exit(0);
|
||||
|
||||
fail:
|
||||
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if (g_dev != nullptr) {
|
||||
delete g_dev;
|
||||
g_dev = nullptr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user