aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paxmacho.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/paxmacho.c b/paxmacho.c
index 142af6e..638453a 100644
--- a/paxmacho.c
+++ b/paxmacho.c
@@ -190,11 +190,15 @@ inline static uint32_t read_mach_header(fatobj *fobj, void *addr)
fatobj *readmacho(const char *filename)
{
int fd;
+ fatobj *ret;
if ((fd = open(filename, O_RDONLY)) == -1)
return NULL;
- return readmacho_fd(filename, fd, 0);
+ ret = readmacho_fd(filename, fd, 0);
+ if (ret == NULL)
+ close(fd);
+ return ret;
}
fatobj *readmacho_fd(const char *filename, int fd, size_t len)