aboutsummaryrefslogtreecommitdiff
path: root/lib/libmd
diff options
context:
space:
mode:
authorJonathan T. Looney <jtl@FreeBSD.org>2015-12-30 18:04:50 +0000
committerJonathan T. Looney <jtl@FreeBSD.org>2015-12-30 18:04:50 +0000
commit8d03d93fb7d6828804a37895a7eb14668d5b73a7 (patch)
tree188fdd4a7c6d8cce2d036a85f1bcaac0086f6a96 /lib/libmd
parent5f0a5fefc661aea4aba7c21ba3d6a840fcd666a9 (diff)
Notes
Diffstat (limited to 'lib/libmd')
-rw-r--r--lib/libmd/mdXhl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index f2e918f548d9..378d8adfafc0 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -59,14 +59,18 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
f = open(filename, O_RDONLY);
if (f < 0)
return 0;
- if (fstat(f, &stbuf) < 0)
- return 0;
+ if (fstat(f, &stbuf) < 0) {
+ i = -1;
+ goto error;
+ }
if (ofs > stbuf.st_size)
ofs = stbuf.st_size;
if ((len == 0) || (len > stbuf.st_size - ofs))
len = stbuf.st_size - ofs;
- if (lseek(f, ofs, SEEK_SET) < 0)
- return 0;
+ if (lseek(f, ofs, SEEK_SET) < 0) {
+ i = -1;
+ goto error;
+ }
n = len;
i = 0;
while (n > 0) {
@@ -79,6 +83,7 @@ MDXFileChunk(const char *filename, char *buf, off_t ofs, off_t len)
MDXUpdate(&ctx, buffer, i);
n -= i;
}
+error:
e = errno;
close(f);
errno = e;