File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,13 @@ fn read_subframe_header<R: ReadBytes>(input: &mut Bitstream<R>) -> Result<Subfra
7676 1 + try!( input. read_unary ( ) )
7777 } ;
7878
79+ // The spec puts no bounds on the number of wasted bits per sample, but more
80+ // than 31 does not make sense, as it would remove all data even for 32-bit
81+ // samples.
82+ if wasted_bits > 31 {
83+ return fmt_err ( "wasted bits per sample must not exceed 31" ) ;
84+ }
85+
7986 let subframe_header = SubframeHeader {
8087 sf_type : sf_type,
8188 wasted_bits_per_sample : wasted_bits,
@@ -199,7 +206,7 @@ pub fn decode<R: ReadBytes>(input: &mut Bitstream<R>,
199206 // the left. Note: it might be better performance-wise to do this on
200207 // the fly while decoding. That could be done if this is a bottleneck.
201208 if header. wasted_bits_per_sample > 0 {
202- debug_assert ! ( header. wasted_bits_per_sample < 31 ,
209+ debug_assert ! ( header. wasted_bits_per_sample <= 31 ,
203210 "Cannot shift by more than the sample width." ) ;
204211 for s in buffer {
205212 // For a valid FLAC file, this shift does not overflow. For an
You can’t perform that action at this time.
0 commit comments