We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7e51cc9 commit c09d79bCopy full SHA for c09d79b
src/decoder.rs
@@ -464,7 +464,12 @@ impl<R: Read> Decoder<R> {
464
465
let frame = self.frame.as_ref().unwrap();
466
467
- if frame.output_size.width as u64 * frame.output_size.height as u64 * frame.components.len() as u64 > self.decoding_buffer_size_limit as u64 {
+ if {
468
+ let required_mem = frame.components.len()
469
+ .checked_mul(frame.output_size.width.into())
470
+ .and_then(|m| m.checked_mul(frame.output_size.height.into()));
471
+ required_mem.map_or(true, |m| self.decoding_buffer_size_limit < m)
472
+ } {
473
return Err(Error::Format("size of decoded image exceeds maximum allowed size".to_owned()));
474
}
475
0 commit comments