Skip to content

Fix tabix NULL deref on open failure and dead detect=0 code#2532

Open
sirus20x6 wants to merge 1 commit intosamtools:developfrom
sirus20x6:fix/tabix-fixes
Open

Fix tabix NULL deref on open failure and dead detect=0 code#2532
sirus20x6 wants to merge 1 commit intosamtools:developfrom
sirus20x6:fix/tabix-fixes

Conversation

@sirus20x6
Copy link

Summary

  • Add NULL check on bgzf_open return in the read-all branch — was guaranteed to crash if the file could not be opened
  • Move detect = 0 from inside the error else block (dead code after return 1) to after the type-matching block — -p preset was being overridden by filename auto-detection

Test plan

  • Existing test suite passes (1920/1920)
  • Verify bcftools tabix -p bed foo.vcf.gz uses BED format, not VCF

1. Move `detect = 0` outside the error else-block where it was
   unreachable dead code after `return 1`. It now executes when a
   valid -p type is matched, properly suppressing auto-detection.

2. Add a NULL check on the bgzf_open() return value in the is_all
   branch to avoid dereferencing a NULL pointer when the file cannot
   be opened.
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