summaryrefslogtreecommitdiffstats
path: root/lib/hivex.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hivex.c')
-rw-r--r--lib/hivex.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/hivex.c b/lib/hivex.c
index 946ecf3..fedbb6c 100644
--- a/lib/hivex.c
+++ b/lib/hivex.c
@@ -317,6 +317,13 @@ hivex_open (const char *filename, int flags)
if (full_read (h->fd, h->addr, h->size) < h->size)
goto error;
+
+ /* We don't need the file descriptor along this path, since we
+ * have read all the data.
+ */
+ if (close (h->fd) == -1)
+ goto error;
+ h->fd = -1;
}
/* Check header. */
@@ -539,7 +546,10 @@ hivex_close (hive_h *h)
munmap (h->addr, h->size);
else
free (h->addr);
- r = close (h->fd);
+ if (h->fd >= 0)
+ r = close (h->fd);
+ else
+ r = 0;
free (h->filename);
free (h);