Don't leak a file descriptor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211699 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-06-25 14:35:59 +00:00
parent 3c26b95512
commit 95be6a7c3d

View File

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