Skip to content

Commit

Permalink
riff: fix overflow with u16 for frames_per_block calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sscobici committed Jan 10, 2025
1 parent 76c8d4e commit 393f9bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions symphonia-format-riff/src/wave/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,17 @@ impl WaveFormatChunk {
//| WaveFormatData::Extensible(WaveFormatExtensible { codec, bits_per_sample, .. })
if codec == CODEC_ID_ADPCM_MS =>
{
let frames_per_block = ((((self.block_align - (7 * self.n_channels)) * 8)
/ (bits_per_sample * self.n_channels))
+ 2) as u64;
let frames_per_block = ((self.block_align - (7 * self.n_channels)) as u64 * 8)
/ (bits_per_sample * self.n_channels) as u64
+ 2;
PacketInfo::with_blocks(self.block_align, frames_per_block)
}
FormatData::Adpcm(FormatAdpcm { codec, bits_per_sample, .. })
if codec == CODEC_ID_ADPCM_IMA_WAV =>
{
let frames_per_block = (((self.block_align - (4 * self.n_channels)) * 8)
/ (bits_per_sample * self.n_channels)
+ 1) as u64;
let frames_per_block = ((self.block_align - (4 * self.n_channels)) as u64 * 8)
/ (bits_per_sample * self.n_channels) as u64
+ 1;
PacketInfo::with_blocks(self.block_align, frames_per_block)
}
_ => Ok(PacketInfo::without_blocks(self.block_align)),
Expand Down

0 comments on commit 393f9bb

Please sign in to comment.