From a8acef6c6845920c557ac0d302fe4974ffe9ff44 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. llvm-svn: 211699 --- llvm/lib/Support/Path.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 59c3798..d5a0ec5 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/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)); -- 2.7.4