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
76
76
1 + try!( input. read_unary ( ) )
77
77
} ;
78
78
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
+
79
86
let subframe_header = SubframeHeader {
80
87
sf_type : sf_type,
81
88
wasted_bits_per_sample : wasted_bits,
@@ -199,7 +206,7 @@ pub fn decode<R: ReadBytes>(input: &mut Bitstream<R>,
199
206
// the left. Note: it might be better performance-wise to do this on
200
207
// the fly while decoding. That could be done if this is a bottleneck.
201
208
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 ,
203
210
"Cannot shift by more than the sample width." ) ;
204
211
for s in buffer {
205
212
// For a valid FLAC file, this shift does not overflow. For an
You can’t perform that action at this time.
0 commit comments