Skip to content

Fix missing header finalization and unchecked faidx return#2536

Open
sirus20x6 wants to merge 1 commit intosamtools:developfrom
sirus20x6:fix/unchecked-returns-critical
Open

Fix missing header finalization and unchecked faidx return#2536
sirus20x6 wants to merge 1 commit intosamtools:developfrom
sirus20x6:fix/unchecked-returns-critical

Conversation

@sirus20x6
Copy link

Summary

  • Add missing bcf_hdr_add_sample(args->header, NULL) in gensample_to_vcf (vcfconvert.c) — header was not finalized after adding samples, matching the pattern in haplegendsample_to_vcf
  • Add NULL check on faidx_fetch_seq return in indel_ctx_type (vcfstats.c) — prevents NULL dereference when chromosome is not in the reference

Test plan

  • Existing test suite passes (1920/1920)
  • Verify bcftools convert --gensample2vcf with sample files
  • Verify bcftools stats --ref-file with mismatched reference

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.
@sirus20x6 sirus20x6 force-pushed the fix/unchecked-returns-critical branch from f147033 to 119ffec Compare March 26, 2026 00:54
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.

1 participant