mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 22:58:10 +08:00
srf02: fix resource leak (unclosed fd)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user