From 6bd66237524ad46a3900f492913000e38c1f2fa4 Mon Sep 17 00:00:00 2001 From: BenLangmead Date: Tue, 13 Jun 2017 08:57:52 -0400 Subject: [PATCH] fix for gzip closing issue --- pat.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pat.h b/pat.h index 44b3992..9001468 100644 --- a/pat.h +++ b/pat.h @@ -590,13 +590,21 @@ class CFilePatternSource : public TrimmingPatternSource { virtual ~CFilePatternSource() { if(is_open_) { - assert(fp_ != NULL); - fclose(fp_); - fp_ = NULL; - if(qfp_ != NULL) { + if (compressed_) { + gzclose(zfp_); + zfp_ = NULL; + } + else if (fp_ != stdin) { + fclose(fp_); + fp_ = NULL; + } + if(qfp_ != NULL && qfp_ != stdin) { fclose(qfp_); qfp_ = NULL; } + assert(zfp_ == NULL); + assert(fp_ == NULL || fp_ == stdin); + assert(qfp_ == NULL || qfp_ == stdin); } }