From ca6ebecae23fc0b06bb9ae94904bcaa63d08acaa Mon Sep 17 00:00:00 2001 From: Petr Danecek Date: Fri, 6 Sep 2024 14:48:16 +0100 Subject: [PATCH] Follow the recommended order of operations As suggested in https://github.com/samtools/htslib/issues/1823#issuecomment-2324878014 first comes hts_idx_destroy() followed by sam_close() --- mpileup2/mpileup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpileup2/mpileup.c b/mpileup2/mpileup.c index f041dc38..86ccf614 100644 --- a/mpileup2/mpileup.c +++ b/mpileup2/mpileup.c @@ -399,9 +399,9 @@ void mpileup_destroy(mpileup_t *mplp) int i; for (i=0; inbam; i++) { + if ( mplp->bam[i].iter ) hts_itr_destroy(mplp->bam[i].iter); sam_close(mplp->bam[i].fp); if ( mplp->bam[i].cached_rec ) bam_destroy1(mplp->bam[i].cached_rec); - if ( mplp->bam[i].iter ) hts_itr_destroy(mplp->bam[i].iter); } for (i=0; inbam_names; i++) free(mplp->bam_names[i]); free(mplp->bam);