From 7d492b0fae7dbf3d25e0fa252de62c29c921766b Mon Sep 17 00:00:00 2001 From: zhumos Date: Wed, 9 Aug 2023 14:57:32 +1000 Subject: [PATCH] Address FTP file descriptor leak as described in issue #2108 --- src/mavsdk/core/mavlink_ftp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mavsdk/core/mavlink_ftp.cpp b/src/mavsdk/core/mavlink_ftp.cpp index e45808deb6..8965dd2f6b 100644 --- a/src/mavsdk/core/mavlink_ftp.cpp +++ b/src/mavsdk/core/mavlink_ftp.cpp @@ -1024,6 +1024,11 @@ MavlinkFtp::ServerResult MavlinkFtp::_work_list(PayloadHeader* payload, bool lis memcpy(&payload->data[offset], entry_s.c_str(), len); offset += len; } + + if (const int close_result = closedir(dfd); close_result != 0) { + LogWarn() << "FTP: Failed to close file descriptor (potential resource leak!). " + "Error code: " << close_result; + } } payload->size = offset;