Skip to content

Commit

Permalink
Address FTP file descriptor leak as described in issue #2108
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhumos committed Aug 11, 2023
1 parent a14d604 commit 88850aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mavsdk/core/mavlink_ftp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,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;
Expand Down

0 comments on commit 88850aa

Please sign in to comment.