From 84cdc70b4a00a7a2938ff8f3c782cfd78ab069b8 Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Thu, 15 Aug 2013 12:39:41 +0000 Subject: Fixed double close() --- src/htszlib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/htszlib.c b/src/htszlib.c index 47cb53c..7718c72 100644 --- a/src/htszlib.c +++ b/src/htszlib.c @@ -54,13 +54,14 @@ Please visit our Website: http://www.httrack.com /* Note: utf-8 */ int hts_zunpack(char *filename, char *newfile) { int ret = -1; - char catbuff[CATBUFF_SIZE]; if (filename != NULL && newfile != NULL) { if (filename[0] && newfile[0]) { + char catbuff[CATBUFF_SIZE]; FILE *const in = FOPEN(fconv(catbuff, filename), "rb"); - const int fd_in = in != NULL ? fileno(in) : -1; - gzFile gz = gzdopen(fd_in, "rb"); + const int fd = in != NULL ? fileno(in) : -1; + // Note: we must dup to be able to flose cleanly. + gzFile gz = fd != -1 ? gzdopen(dup(fd), "rb") : NULL; if (gz) { FILE *const fpout = FOPEN(fconv(catbuff, newfile), "wb"); -- cgit v1.2.3