[libcxx-commits] [PATCH] D90601: [libcxx] Avoid double frees of file descriptors in the fallback ifstream/ofstream codepath

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 2 05:50:51 PST 2020


mstorsjo created this revision.
mstorsjo added a reviewer: libc++.
Herald added a project: libc++.
Herald added 1 blocking reviewer(s): libc++.
mstorsjo requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90601

Files:
  libcxx/src/filesystem/operations.cpp


Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -684,12 +684,14 @@
       ec = capture_errno();
       return false;
     }
+    read_fd.fd = -1;
     ofstream out;
     out.__open(write_fd.fd, ios::binary);
     if (!out.is_open()) {
       ec = capture_errno();
       return false;
     }
+    write_fd.fd = -1;
 
     if (in.good() && out.good()) {
       using InIt = istreambuf_iterator<char>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90601.302253.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201102/4b956dc1/attachment.bin>


More information about the libcxx-commits mailing list