Skip to content

Commit

Permalink
ftp: odd potential segfault fix
Browse files Browse the repository at this point in the history
Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes committed Oct 25, 2023
1 parent aca7977 commit bb2e7d0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mavsdk/core/mavlink_ftp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,11 @@ MavlinkFtpClient::list_directory(const std::string& path)
std::promise<std::pair<ClientResult, std::vector<std::string>>> prom;
auto fut = prom.get_future();

list_directory_async(
path, [&prom](const ClientResult result, const std::vector<std::string> dirs) {
prom.set_value(std::make_pair(result, dirs));
});
list_directory_async(path, [&](const ClientResult result, const std::vector<std::string> dirs) {
// Somehow capturing "this" prevents a segfault in pthread_once on Ubuntu 20.04.
(void)this;
prom.set_value(std::make_pair(result, dirs));
});

return fut.get();
}
Expand Down

0 comments on commit bb2e7d0

Please sign in to comment.