Permalink
Browse files

fix for gzip closing issue

  • Loading branch information...
1 parent ddb3ac7 commit 6bd66237524ad46a3900f492913000e38c1f2fa4 @BenLangmead committed Jun 13, 2017
Showing with 12 additions and 4 deletions.
  1. +12 −4 pat.h
View
16 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);
}
}

0 comments on commit 6bd6623

Please sign in to comment.