Skip to content

Commit db09380

Browse files
authored
Merge pull request #20 from actboy168/patch-2
Fix an fd leak
2 parents ca969ab + 4a749c0 commit db09380

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/ghc/filesystem.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
31153115
ec = std::error_code(errno, std::system_category());
31163116
return false;
31173117
}
3118-
std::shared_ptr<void> guard_out(nullptr, [out](void*) { ::close(out); });
3118+
std::shared_ptr<void> guard_in(nullptr, [in](void*) { ::close(in); });
31193119
int mode = O_CREAT | O_WRONLY | O_TRUNC;
31203120
if (!overwrite) {
31213121
mode |= O_EXCL;
@@ -3124,7 +3124,7 @@ GHC_INLINE bool copy_file(const path& from, const path& to, copy_options options
31243124
ec = std::error_code(errno, std::system_category());
31253125
return false;
31263126
}
3127-
std::shared_ptr<void> guard_in(nullptr, [in](void*) { ::close(in); });
3127+
std::shared_ptr<void> guard_out(nullptr, [out](void*) { ::close(out); });
31283128
ssize_t br, bw;
31293129
while ((br = ::read(in, buffer.data(), buffer.size())) > 0) {
31303130
int offset = 0;

0 commit comments

Comments
 (0)