From 72e0c0601b75930c34ace84347459700fa2ae257 Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Wed, 21 May 2014 17:01:30 +0000 Subject: Cleaner dup --- src/htszlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/htszlib.c b/src/htszlib.c index 5042910..05cc457 100644 --- a/src/htszlib.c +++ b/src/htszlib.c @@ -59,8 +59,9 @@ int hts_zunpack(char *filename, char *newfile) { char catbuff[CATBUFF_SIZE]; FILE *const in = FOPEN(fconv(catbuff, sizeof(catbuff), filename), "rb"); const int fd = in != NULL ? fileno(in) : -1; + const int dup_fd = fd != -1 ? dup(fd) : -1; // Note: we must dup to be able to flose cleanly. - gzFile gz = fd != -1 ? gzdopen(dup(fd), "rb") : NULL; + const gzFile gz = dup_fd != -1 ? gzdopen(dup_fd, "rb") : NULL; if (gz) { FILE *const fpout = FOPEN(fconv(catbuff, sizeof(catbuff), newfile), "wb"); -- cgit v1.2.3