[llvm] r211699 - Don't leak a file descriptor.

Rafael Espindola rafael.espindola at gmail.com
Wed Jun 25 07:35:59 PDT 2014


Author: rafael
Date: Wed Jun 25 09:35:59 2014
New Revision: 211699

URL: http://llvm.org/viewvc/llvm-project?rev=211699&view=rev
Log:
Don't leak a file descriptor.

Modified:
    llvm/trunk/lib/Support/Path.cpp

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=211699&r1=211698&r2=211699&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Wed Jun 25 09:35:59 2014
@@ -1065,7 +1065,7 @@ std::error_code identify_magic(const Twi
 
   char Buffer[32];
   int Length = read(FD, Buffer, sizeof(Buffer));
-  if (Length < 0)
+  if (close(FD) != 0 || Length < 0)
     return std::error_code(errno, std::generic_category());
 
   Result = identify_magic(StringRef(Buffer, Length));





More information about the llvm-commits mailing list