Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix hts_hfile() for compressed text_format files
SAM and VCF files opened for write both start with htsFile::format.format set to text_format, and then update it after writing the header. This means it's possible to open a text_format file with compression, so hts_hfile() needs to handle it in the same way as sam and vcf. Noticed when hts_set_opt(fpout, HTS_OPT_BLOCK_SIZE, BAM_BLOCK_SIZE) failed in samtools sort in the case where fpout was a compressed sam file. At this point fpout was a text_file, so the wrong pointer was passed to hfile_set_blksize(), which luckily bailed out and returned -1 before doing any damage to the incorrectly passed-in structure.
- Loading branch information