Don't leak a file descriptor.

llvm-svn: 211699
This commit is contained in:
Rafael Espindola 2014-06-25 14:35:59 +00:00
parent 1de35e719f
commit a8acef6c68
1 changed files with 1 additions and 1 deletions

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