mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
srf02: fix resource leak (unclosed fd)
This commit is contained in:
@@ -700,7 +700,7 @@ void info();
|
|||||||
void
|
void
|
||||||
start(uint8_t rotation)
|
start(uint8_t rotation)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd = -1;
|
||||||
|
|
||||||
if (g_dev != nullptr) {
|
if (g_dev != nullptr) {
|
||||||
errx(1, "already started");
|
errx(1, "already started");
|
||||||
@@ -728,10 +728,15 @@ start(uint8_t rotation)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
|
if (fd >= 0) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (g_dev != nullptr) {
|
if (g_dev != nullptr) {
|
||||||
delete g_dev;
|
delete g_dev;
|
||||||
g_dev = nullptr;
|
g_dev = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user