From 47e668eb86531130bcc22b29f82d62eaa57704a6 Mon Sep 17 00:00:00 2001 From: Patrick Servello Date: Mon, 9 Sep 2019 12:24:07 -0500 Subject: [PATCH] simulator and dumpfile fix minor resource leaks * Certain conditional branches returned before closing the file handler. --- src/modules/simulator/simulator_mavlink.cpp | 1 + src/systemcmds/dumpfile/dumpfile.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/modules/simulator/simulator_mavlink.cpp b/src/modules/simulator/simulator_mavlink.cpp index 422c31a1ac..89aeddc9ed 100644 --- a/src/modules/simulator/simulator_mavlink.cpp +++ b/src/modules/simulator/simulator_mavlink.cpp @@ -673,6 +673,7 @@ void Simulator::poll_for_MAVLink_messages() if (bind(_fd, (struct sockaddr *)&_myaddr, sizeof(_myaddr)) < 0) { PX4_ERR("bind for UDP port %i failed (%i)", _port, errno); + ::close(_fd); return; } diff --git a/src/systemcmds/dumpfile/dumpfile.c b/src/systemcmds/dumpfile/dumpfile.c index 981c701b6d..8f2e798944 100644 --- a/src/systemcmds/dumpfile/dumpfile.c +++ b/src/systemcmds/dumpfile/dumpfile.c @@ -99,6 +99,7 @@ dumpfile_main(int argc, char *argv[]) if (tcsetattr(out, TCSANOW, &tc) < 0) { PX4_ERR("failed setting stdout attributes"); + fclose(f); return 1; }