From 119ffec333923f0339b96a42b66ad3f5a5d19b27 Mon Sep 17 00:00:00 2001 From: sirus20x6 Date: Wed, 25 Mar 2026 19:01:52 -0500 Subject: [PATCH] Fix missing header finalization and unchecked faidx_fetch_seq return In gensample_to_vcf (vcfconvert.c), add the missing bcf_hdr_add_sample(header, NULL) finalization call after the sample addition loop, matching the pattern used in haplegendsample_to_vcf and other converters. In indel_ctx_type (vcfstats.c), check faidx_fetch_seq return for NULL before dereferencing. If the chromosome is absent from the reference, return the default indel length with nrep=0, nlen=0 instead of crashing with a NULL pointer dereference. --- vcfconvert.c | 1 + vcfstats.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/vcfconvert.c b/vcfconvert.c index 7b14d43c5..c46d9c72f 100644 --- a/vcfconvert.c +++ b/vcfconvert.c @@ -489,6 +489,7 @@ static void gensample_to_vcf(args_t *args) *se = 0; bcf_hdr_add_sample(args->header,samples[i]); } + bcf_hdr_add_sample(args->header,NULL); for (i=0; iref, chr, pos-1, pos+win_size, &fai_ref_len); + if ( !fai_ref ) + { + *nrep = 0; + *nlen = 0; + return alt_len - ref_len; + } for (i=0; i96 ) fai_ref[i] -= 32;