Skip to content

Fix leak of region list in hts_itr_multi_bam() - #2084

Open
daviesrob wants to merge 1 commit into
samtools:developfrom
daviesrob:fix-region-list-leak
Open

Fix leak of region list in hts_itr_multi_bam()#2084
daviesrob wants to merge 1 commit into
samtools:developfrom
daviesrob:fix-region-list-leak

Conversation

@daviesrob

Copy link
Copy Markdown
Member

If the regions include one of the special tid values HTS_IDX_NONE, HTS_IDX_START, or HTS_IDX_REST then the hts_itr_t::reg_list array is dropped and set to NULL, and hts_itr_t::n_reg is set to zero. As the pointer is set to NULL, it's necessary to call hts_reglist_free() here to clean up the structure first else the contents are no longer accessible and get leaked.

If the regions include one of the special tid values
HTS_IDX_NONE, HTS_IDX_START, or HTS_IDX_REST then the
hts_itr_t::reg_list array is dropped and set to
NULL, and hts_itr_t::n_reg is set to zero.  As the
pointer is set to NULL, it's necessary to call
hts_reglist_free() here to clean up the structure
first else the contents are no longer accessible
and get leaked.

Signed-off-by: Rob Davies <rmd+git@sanger.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants