Skip to content

fix/prevent-wav-5gb-alloc: Prevent integer underflow in decoder::wav::SamplesIterator::next causing 5 GB allocation when reading certain WAV files - #933

Open
marin-m wants to merge 1 commit into
RustAudio:masterfrom
marin-m:fix/prevent-wav-5gb-alloc
Open

marin-m wants to merge 1 commit into
RustAudio:masterfrom
marin-m:fix/prevent-wav-5gb-alloc

Conversation

@marin-m

@marin-m marin-m commented Oct 25, 2026

Copy link
Copy Markdown

Should fix #929 (originally reported at marin-m/SongRec#341)

…::SamplesIterator::next` causing 5 GB allocation when reading certain WAV files
@marin-m
marin-m force-pushed the fix/prevent-wav-5gb-alloc branch from 1ce4a53 to c6b8807 Compare October 25, 2026 09:21

@kapok-4o kapok-4o left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reproduced #929 with a 3-sample mono WAV through Decoder::new_wav (hound feature): reading past the end and then calling size_hint() panics with "attempt to subtract with overflow" at wav.rs:176 on master, and returns (0, Some(0)) here. Could you add that as a regression test? Separately, and not from this PR: size_hint doesn't count silence_samples_remaining, so a file that ends mid-frame yields more samples than the reported upper bound.

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.

WavDecoder::size_hint underflows (u32 wrap, ~4.29e9) after EOF, causes multi-GB Vec::collect() allocation

2 participants