[PATCH] D31278: [XRay] [compiler-rt] Plug a file descriptor leak in a failure case.

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 23:58:24 PDT 2017

pelikan created this revision.

Fd needs to be closed before the number gets out of scope.



Index: lib/xray/xray_x86_64.cc
--- lib/xray/xray_x86_64.cc
+++ lib/xray/xray_x86_64.cc
@@ -44,9 +44,9 @@
   ssize_t BytesRead;
   bool Success;
   std::tie(BytesRead, Success) = retryingReadSome(Fd, Line, Line + BufSize);
+  close(Fd);
   if (!Success)
     return false;
-  close(Fd);
   char *End = nullptr;
   long long Tmp = internal_simple_strtoll(Line, &End, 10);
   bool Result = false;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31278.92763.patch
Type: text/x-patch
Size: 462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170323/e20cccea/attachment.bin>

More information about the llvm-commits mailing list