From 95be6a7c3d841e2d30a96579d4fe8457748477fa Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 25 Jun 2014 14:35:59 +0000 Subject: [PATCH] Don't leak a file descriptor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211699 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Path.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 59c37987127..d5a0ec55c68 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -1065,7 +1065,7 @@ std::error_code identify_magic(const Twine &Path, file_magic &Result) { 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));