Skip to content

Fix bit overflows when writing headers#3439

Merged
lu-zero merged 1 commit intoxiph:masterfrom
sdroege:bitstream-io-4-overflows
Jun 11, 2025
Merged

Fix bit overflows when writing headers#3439
lu-zero merged 1 commit intoxiph:masterfrom
sdroege:bitstream-io-4-overflows

Conversation

@sdroege
Copy link
Copy Markdown
Contributor

@sdroege sdroege commented Jun 11, 2025

bw.write(5, 31) is writing an 31i32 but that doesn't fit into 5 bits because of the sign bit.

As part of this, also move everything to the non-compat BitWrite trait.

bw.write_bit(true)?; // marker
bw.write(7, 1)?; // version
bw.write(3, seq.profile)?;
bw.write(5, 31)?; // level
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, this line was always panicking for me.

Unclear why the CI / tests here are not catching that.

`bw.write(5, 31)` is writing an 31i32 but that doesn't fit into 5 bits because
of the sign bit.

As part of this, also move everything to the non-compat `BitWrite` trait.
@sdroege sdroege force-pushed the bitstream-io-4-overflows branch from d0dc232 to 0b8af98 Compare June 11, 2025 12:56
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 41.81818% with 64 lines in your changes missing coverage. Please review.

Project coverage is 82.31%. Comparing base (3c3a26f) to head (0b8af98).
Report is 75 commits behind head on master.

Files with missing lines Patch % Lines
src/header.rs 46.00% 54 Missing ⚠️
src/api/context.rs 0.00% 6 Missing ⚠️
src/ec.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3439      +/-   ##
==========================================
- Coverage   88.52%   82.31%   -6.22%     
==========================================
  Files          89       84       -5     
  Lines       28323    27086    -1237     
==========================================
- Hits        25074    22296    -2778     
- Misses       3249     4790    +1541     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@lu-zero lu-zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'll roll a 0.8.1 with it this weekend.

@lu-zero lu-zero merged commit b0bd2ad into xiph:master Jun 11, 2025
24 of 26 checks passed
@sdroege sdroege deleted the bitstream-io-4-overflows branch June 12, 2025 06:52
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