diff --git a/src/mavsdk/core/mavlink_ftp.cpp b/src/mavsdk/core/mavlink_ftp.cpp index 14ed043100..a4b268e4be 100644 --- a/src/mavsdk/core/mavlink_ftp.cpp +++ b/src/mavsdk/core/mavlink_ftp.cpp @@ -1027,6 +1027,12 @@ 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;