Skip to content

Commit

Permalink
Merge pull request #20 from actboy168/patch-2
Browse files Browse the repository at this point in the history
Fix an fd leak
  • Loading branch information
gulrak committed May 23, 2019
2 parents ca969ab + 4a749c0 commit db09380
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
ec = std::error_code(errno, std::system_category());
return false;
}
std::shared_ptr<void> guard_out(nullptr, [out](void*) { ::close(out); });
std::shared_ptr<void> guard_in(nullptr, [in](void*) { ::close(in); });
int mode = O_CREAT | O_WRONLY | O_TRUNC;
if (!overwrite) {
mode |= O_EXCL;
Expand All @@ -3124,7 +3124,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
ec = std::error_code(errno, std::system_category());
return false;
}
std::shared_ptr<void> guard_in(nullptr, [in](void*) { ::close(in); });
std::shared_ptr<void> guard_out(nullptr, [out](void*) { ::close(out); });
ssize_t br, bw;
while ((br = ::read(in, buffer.data(), buffer.size())) > 0) {
int offset = 0;
Expand Down

0 comments on commit db09380

Please sign in to comment.