[compiler-rt] r298685 - [XRay] [compiler-rt] Plug a file descriptor leak in a failure case.

Martin Pelikan via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 22:02:51 PDT 2017


Author: pelikan
Date: Fri Mar 24 00:02:51 2017
New Revision: 298685

URL: http://llvm.org/viewvc/llvm-project?rev=298685&view=rev
Log:
[XRay] [compiler-rt] Plug a file descriptor leak in a failure case.

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

Reviewers: dberris

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31278

Modified:
    compiler-rt/trunk/lib/xray/xray_x86_64.cc

Modified: compiler-rt/trunk/lib/xray/xray_x86_64.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_x86_64.cc?rev=298685&r1=298684&r2=298685&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_x86_64.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_x86_64.cc Fri Mar 24 00:02:51 2017
@@ -44,9 +44,9 @@ static bool readValueFromFile(const char
   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;




More information about the llvm-commits mailing list