diff options
author | Xavier Roche <xroche@users.noreply.github.com> | 2013-08-15 12:39:41 +0000 |
---|---|---|
committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-08-15 12:39:41 +0000 |
commit | 84cdc70b4a00a7a2938ff8f3c782cfd78ab069b8 (patch) | |
tree | 54299ef8d7ce2659279b6e21776ebe2b6926403b /src | |
parent | ea741caba70b90cf89305cfcb0bff789cdb9e84e (diff) |
Fixed double close()
Diffstat (limited to 'src')
-rw-r--r-- | src/htszlib.c | 7 |
1 files changed, 4 insertions, 3 deletions
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"); |