From c814d3983fc3f04fdedcdc3f359d369f7d877cbd Mon Sep 17 00:00:00 2001 From: Rob Davies Date: Tue, 28 Jan 2025 10:27:23 +0000 Subject: [PATCH] Reset variant types after updating alleles Variant type calls produced by bcf_set_variant_types() may be stale after updating alleles via bcf_update_alleles() or bcf_update_alleles_str(), so set d.var_type to -1 to force a recalculation. Fixes an out of bounds access in bcftools consensus that occurred when it added a new allele to a record. --- vcf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vcf.c b/vcf.c index 549fcb710..ba68825df 100644 --- a/vcf.c +++ b/vcf.c @@ -5495,6 +5495,7 @@ int bcf_has_filter(const bcf_hdr_t *hdr, bcf1_t *line, char *filter) static inline int _bcf1_sync_alleles(const bcf_hdr_t *hdr, bcf1_t *line, int nals) { line->d.shared_dirty |= BCF1_DIRTY_ALS; + line->d.var_type = -1; line->n_allele = nals; hts_expand(char*, line->n_allele, line->d.m_allele, line->d.allele);