Commit cbe30577 authored by Guillem Jover's avatar Guillem Jover

Fix file descriptor leak in HASHFileChunk helper

This leak only happens on error conditions, so it's not too bad.

Warned-by: coverity
parent 5a32ea0a
......@@ -67,8 +67,10 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
}
len = sb.st_size;
}
if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0))
if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0)) {
close(fd);
return (NULL);
}
while ((nr = read(fd, buffer,
(size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment