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));